A WooCommerce store needed to display a “Better Price in Cart” message on select product pages while hiding the actual discounted price until the item is added to the cart. This is a common requirement for B2B or manufacturer-restricted pricing, where showing lower prices publicly is not allowed.
This guide explains how to implement this functionality using native WooCommerce pricing, a custom product flag, and minor template customization—without breaking coupons, inventory systems, or pricing logic.
Issue Background
The goal was to:
- Display a crossed-out regular price on the product page
- Show a message like “Better Price in Cart”
- Hide the actual sale price on the product page
- Apply the discounted price only in the cart and checkout
Additionally, this needed to apply only to specific SKUs and be controlled via a custom flag managed through a PIM importer.
Diagnosis
WooCommerce already handles pricing logic natively
WooCommerce supports regular and sale prices out of the box. When both are set, it automatically shows the regular price crossed out and uses the sale price in cart and checkout. However, it also displays the sale price on the product page by default.
Need for SKU-level control
A custom product field (price_in_cart) allows selective control over which products display this behavior and enables management via CSV or PIM import.
Potential conflict with volume pricing
Volume discounts calculate from the regular price. If combined with this feature, pricing could become inconsistent. These features should remain mutually exclusive.
Resolution Steps
Use WooCommerce regular and sale prices
Set the regular price (displayed crossed out) and the sale price (used in cart and checkout).
Add custom product flag
Create a custom field price_in_cart and set it to true/false (or Y/N via import).
Modify product page display
Conditionally hide the sale price when the flag is enabled and display a message like:
<span class="price-label">Better Price in Cart!</span>
Keep cart and checkout pricing unchanged
WooCommerce will automatically use the sale price in cart and checkout without additional customization.
Update PIM importer
Add support for a price_in_cart column using Y/N values to control behavior at scale.
Style and UX adjustments
- Display message near price or below it
- Optionally adjust Add to Cart button text
Validate integrations
- Coupons apply correctly on cart price
- Inventory systems (SFM) remain unaffected
- Core WooCommerce pricing logic remains intact
Final Outcome
The solution delivered a clean “Better Price in Cart” experience for selected products, with hidden sale prices on the product page and accurate pricing in cart and checkout. The implementation is scalable via PIM import and maintains compatibility with WooCommerce features.
If you need help customizing WooCommerce pricing or building advanced B2B functionality, contact Freshy and we’ll help you implement it the right way.