Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โDisplay both regular and sale prices in WooCommerce cart table with strikethrough formatting. Use woocommerce_cart_item_price filter to show customers savings clearly, improving transparency and highlighting discounts for better shopping experience and conversions.
Want to show both the original (regular) and discounted (sale) prices in the WooCommerce cart? Use the woocommerce_cart_item_price filter to do this easily. Step 1: Go to your theme’s functions.php file. Step 2: Paste this code into the file:
// Show regular and sale prices in cart table
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);
Step 3: Save and upload the updated file. Now, your cart table will display the regular price as a strikethrough and the sale price as highlighted. This visual cue helps customers clearly see the savings. If you're using a custom cart template, some CSS or template adjustments may be needed. 
Search our archives or reach out to our team for solutions and expert advice.