Highlight Product Discounts in the WooCommerce Cart Page

Increase conversion rates by visually emphasizing discounts in the WooCommerce shopping cart. Use the woocommerce_cart_item_price filter to detect if a product is on sale using the is_on_sale method. Modify the price output to include the regular price wrapped in HTML <del> tags and the current sale price in <ins> tags. This transparent pricing strategy reminds customers of the value they are receiving before they proceed to checkout, reducing cart abandonment and improving the overall perceived value of your promotional offers.

Display Both Sale &#038; Regular Prices in WooCommerce Cart

Advanced Guides Code Snippets Coding Blog Content Management E-Commerce Tips PHP PHP Debugging PHP Development PHP Snippets Woocommerce WooCommerce Custom Code Woocommerce Hooks WooCommerce Tips Wordpress WordPress Code Snippets WordPress Development WordPress Functions WordPress Snippets WordPress Tutorials WP Hooks

Display Both Sale &#038; Regular Prices in WooCommerce Cart Tutorial/Guide

To help customers understand how much they’re saving, you can show both the sale price and the regular price right in the WooCommerce cart. Here’s how to implement this using a filter. Step 1: Open the functions.php file of your current theme. Step 2: Add this PHP code snippet:

// Display regular and sale price in cart
function modify_cart_item_price($product_price, $cart_item, $cart_item_key) {
    $product = $cart_item['data'];

    if ($product->is_on_sale()) {
        $regular_price = wc_price($product->get_regular_price());
        $sale_price = wc_price($product->get_price());

        $product_price = '<del>' . $regular_price . '</del> <ins>' . $sale_price . '</ins>';
    }

    return $product_price;
}
add_filter('woocommerce_cart_item_price', 'modify_cart_item_price', 10, 3);

Once added, WooCommerce will render a crossed-out original price followed by the sale price for every discounted item in the cart. This helps improve user experience by visually emphasizing discounts. Make sure it blends well with your theme’s design, especially if using a custom cart layout.  

๐Ÿ’ก Have a Coding Problem?

Search our archives or reach out to our team for solutions and expert advice.