This topic has 9 replies, 3 voices, and was last updated 5 years, 5 months ago ago by Olga Barlow
Hello, is it possible to display sale price variant products in the same fashion as single product prices on category pages?
Ex:
Original Price Sale Price
Using Numbers:
$49.99 $15.99
Hello,
Go to Theme Options > Shop elements > Variation swatches > Variation swatches > Off.
Regards
That seems to have no effect even after clearing the cache?
Items with variation opens do not show the original price slashed with sale price in blue but products with no variations do.
Please see screenshot – http://prntscr.com/nz971f
Regards
For some reason its not applying to all variant products, is there an option to have it applied only to certain products that I am missing in the theme options?
I apologize my description was not succinct of my problem to begin with, its specifically not applying to variant products where the variants have different prices. Would like if the low end or high end could be displayed at sale price, is this possible?
Hello,
If you want to display sale price for the variable products in the following way http://prntscr.com/o02q7z, unfortunately, WooCommerce does not have such option. You may try to implement this only by additional customization. You can submit customization request here.
Regards
Thank you for your response.
For anyone who comes across this problem, this is the code that worked for me to achieve the results.
//add variation sale strikethrough with original price on shop and category pages
function wc_wc20_variation_price_format($price, $product) {
// Main Price
$prices = array($product->get_variation_price('min', true), $product->get_variation_price('max', true));
$price_min = $prices[0] !== $prices[1] ? sprintf(__('%1$s', 'woocommerce'), wc_price($prices[0])) : wc_price($prices[0]);
$price_max = $prices[0] !== $prices[1] ? sprintf(__('%1$s', 'woocommerce'), wc_price($prices[1])) : wc_price($prices[1]);
// Sale Price
$prices = array($product->get_variation_regular_price('min', true), $product->get_variation_regular_price('max', true));
sort($prices);
$saleprice_min = $prices[0] !== $prices[1] ? sprintf(__('%1$s', 'woocommerce'), wc_price($prices[0])) : wc_price($prices[0]);
$saleprice_max = $prices[0] !== $prices[1] ? sprintf(__('%1$s', 'woocommerce'), wc_price($prices[1])) : wc_price($prices[1]);
if ($price_min !== $saleprice_min || $price_max !== $saleprice_max) {
$del = $saleprice_min === $saleprice_max ? $saleprice_min : "$saleprice_min - $saleprice_max";
$ins = $price_min === $price_max ? $price_min : "$price_min - $price_max";
return "<del>$del</del> <ins>$ins</ins>";
}
return $price;
}
add_filter('woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2);
add_filter('woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2);
Hello,
Thank you that you shared your solution. Probably it will be useful for somebody with the same request.
Regards
You must be logged in to reply to this topic.Log in/Sign up