Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradleysa/f41cf8c6e8dc7534d276b84f28b1564f to your computer and use it in GitHub Desktop.
Save bradleysa/f41cf8c6e8dc7534d276b84f28b1564f to your computer and use it in GitHub Desktop.
WC: Slashed Cart Subtotal if Coupon Applied
add_filter( 'woocommerce_cart_subtotal', 'bbloomer_slash_cart_subtotal_if_discount', 99, 3 );
function bbloomer_slash_cart_subtotal_if_discount( $cart_subtotal, $compound, $obj ){
global $woocommerce;
if ( $woocommerce->cart->get_cart_discount_total() <> 0 ) {
$new_cart_subtotal = wc_price( WC()->cart->subtotal - $woocommerce->cart->get_cart_discount_tax_total() - $woocommerce->cart->get_cart_discount_total() );
$cart_subtotal = sprintf( '<del>%s</del> <b>%s</b>', $cart_subtotal , $new_cart_subtotal );
}
return $cart_subtotal;
}
/** https://www.businessbloomer.com/woocommerce-slashed-cart-subtotal-coupon-cart/ **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment