Display Regular And Sale Price in WooCommerce Cart Table

If you want to display regular and sale price in the cart table. add the following code in the functions.php file

add_filter( 'woocommerce_cart_item_price', 'bbloomer_change_cart_table_price_display', 30, 3 );
function bbloomer_change_cart_table_price_display( $price, $values, $cart_item_key ) {
   $slashed_price = $values['data']->get_price_html();
   $is_on_sale = $values['data']->is_on_sale();
   if ( $is_on_sale ) {
      $price = $slashed_price;
   }
   return $price;
}

Leave a Reply

Your email address will not be published. Required fields are marked *