Menu Close

WooCommerce: Slashed Cart Subtotal if Coupon @ Cart

default

This is a nice snippet to let users know what the original cart amount was by slashing the cart subtotal and showing the cart subtotal after discounts on the same line (Cart totals > subtotal).

You can then hide the coupon code line if you wish!

WooCommerce: show slashed original and discounted subtotal @ Cart

PHP Snippet: show slashed original and discounted subtotal @ WooCommerce Cart

/**
 * @snippet       Cart subtotal slashed if coupon applied @ WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_cart_subtotal', 'bbloomer_slash_cart_subtotal_if_discount', 9999, 3 );

function bbloomer_slash_cart_subtotal_if_discount( $cart_subtotal, $compound, $cart ){
   if ( $cart->get_cart_discount_total() > 0 ) {
		return wc_format_sale_price( $cart->get_subtotal(), $cart->get_subtotal() - $cart->get_cart_discount_total() );
	}
   return $cart_subtotal;
}
View Source
Posted in WooCommerce Tips