The following code works correctly for single products, but I want to use this code for multiple variations of several kinds of products.
Actually, this code is adding the sale price with the original price before the sale price starts.
I am working on scheduling sales and I want to show both the sale price and the original, pre-sale price so that customers can see how much the discount will save them.
function cw_change_product_price_display( $price_html ) {
global $product;
global $woocommerce;
if ( $product->is_on_sale() ) {
return $price_html;
} elseif($product->get_sale_price()){
$price =wc_price($product->get_sale_price());
return $price_html . $price;
} else {
return $price_html;
}
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
I think your question is not clear but it seems that you should use the following hook to change the variable price of WooCommerce.
add_filter('woocommerce_product_variation_get_price', 'cw_change_product_price_display', 99, 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With