It’s no secret that WooCommerce is one of the most popular eCommerce platforms available. According to BuiltWith, WooCommerce powers 39% of all online stores.
One of the things that makes WooCommerce so popular is its flexibility. There are a ton of different plugins and themes available that allow you to tailor WooCommerce to your specific needs.
One common question we get here at Do the Woo is how to show both the regular price and sale price in WooCommerce. By default, WooCommerce only shows the sale price if there is one active.
However, there are a few different ways you can show both the regular price and sale price in WooCommerce.
1. Use a Plugin
There are a few plugins available that will add the ability to show both the regular and sale price in WooCommerce. One plugin we recommend is WooCommerce Price Based on Country. This plugin is 100% free and available on WordPress.org.
WooCommerce Price Based on Country allows you to show different prices to customers based on their location. You can also set up rules so that certain products are only available in certain countries.
However, you should be aware that showing both the regular price and the sale price may confuse some customers. They may not understand why the prices are different, or they may think that the sale price is the only price that you will ever charge for the product. If you do decide to show both prices, make sure that you explain the sale in a clear and concise way so that customers will know what they are getting.
WooCommerce Price Based on Country also has a setting that allows you to show both the regular and sale price for a product regardless of the customer’s location.
2. Use Custom Code
If you’re comfortable working with code, then you can add a custom function to your child theme’s functions.php file to show both the regular and sale price in WooCommerce.
function wc_show_both_prices() {
global $product;
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
if ( !empty( $regular_price ) ) {
echo '<del>' . wc_price( $regular_price ) .
'</del> <ins>' . wc_price( $sale_price ) . '</ins>';
} else {
echo wc_price( $sale_price );
}
}
add_action( 'woocommerce_after_shop_loop_item', 'wc_show_both_prices', 10 );
class="language-php">function wc_show_both_prices() {
$regular_price = $product->get_regular