How to fix WooCommerce “better price in cart” display issues across product cards

When using dynamic pricing strategies like “Better price in cart,” consistency across your WooCommerce store is critical. In this case, pricing logic was working correctly on product detail pages—but displaying incorrectly across product cards in search results, category pages, and carousels.

The solution involved updating multiple template contexts to ensure pricing messaging remained consistent everywhere products were displayed.

Issue Background

A WooCommerce store implemented a “price_in_cart” flag to hide discounted pricing until the product was added to the cart. This is a common strategy to:

  • Encourage add-to-cart actions
  • Comply with MAP (Minimum Advertised Price) policies
  • Reduce price scraping by competitors

However, inconsistencies appeared across the site:

  • Search results and category pages were showing only the sale price
  • Homepage carousels and product sliders were displaying incorrect pricing combinations
  • Some templates showed a strikethrough retail price but incorrectly paired it with a visible sale price instead of messaging

The expected behavior was:

  • Show the retail price crossed out
  • Display a “Better price in cart” message
  • Avoid showing the actual discounted price before cart interaction

Diagnosis

The root issue wasn’t with WooCommerce pricing itself—it was with template inconsistency.

Different parts of the site were using different template files and rendering logic, including:

  • Product loop templates (shop + category pages)
  • AJAX-powered search results
  • Custom carousel/slider components
  • Manufacturer archive templates

While the Product Detail Page (PDP) handled the price_in_cart flag correctly, these other templates:

  • Ignored the flag entirely, or
  • Rendered default WooCommerce sale pricing

This resulted in mixed and incorrect pricing displays across the user experience.

Resolution Steps

1. Standardize pricing logic across templates

The first step was ensuring all product display contexts respected the same condition:

if ($price_in_cart == 1) {
    // Override default price display
}

2. Replace sale price output with messaging

Instead of showing the sale price, templates were updated to:

  • Display the regular (retail) price with a strikethrough
  • Add a “Better price in cart” label

Example rendering logic:

if ($price_in_cart == 1) {
    echo '<span class="price"><del>' . wc_price($regular_price) . '</del></span>';
    echo '<span class="price-in-cart">Better price in cart</span>';
} else {
    echo $product->get_price_html();
}

3. Update carousel and custom component templates

Custom-built UI components (such as homepage carousels) required separate updates because they often:

  • Use custom queries (WP_Query)
  • Bypass standard WooCommerce hooks

Each component was updated to:

  • Pull the correct product meta (price_in_cart)
  • Apply the same conditional display logic
  • Match styling used on PDPs

4. Align styling with product detail pages

To maintain visual consistency:

  • The “Better price in cart” label was positioned below or next to the strikethrough price
  • Styling matched existing PDP formatting
  • Spacing and hierarchy were adjusted for readability

5. Test across multiple contexts

The fix was validated across:

  • Category pages
  • Manufacturer archive pages
  • Search results
  • Homepage product carousels

Special attention was given to:

  • AJAX-loaded content (e.g., “Load More” buttons)
  • Mobile responsiveness
  • Edge cases where products did not use the flag

Final Outcome

After implementing consistent pricing logic across all templates, the store achieved:

  • Accurate and compliant pricing display across the entire site
  • Improved UX with clear “Better price in cart” messaging
  • Elimination of conflicting price signals
  • A scalable approach for future template additions

This case highlights a common WooCommerce challenge: pricing logic must be centralized and consistently applied across all display contexts—not just product pages.

If your WooCommerce store has inconsistent pricing displays or custom logic that isn’t behaving across templates, contact Freshy.