php - Woocommerce Show only one price for variable product on discount -


here woocommerce website: sweetworldcandy.com

the issue is, in variable product price least , max value showing want if product not on sale show least value if on sale show least value , least value of offer price adding slash delete tag

i shared 3 images below reference:

enter image description here if not on saleenter image description here

the code below should expect:

add_filter('woocommerce_variable_sale_price_html', 'shop_variable_product_price', 10, 2); add_filter('woocommerce_variable_price_html','shop_variable_product_price', 10, 2 ); function shop_variable_product_price( $price, $product ){     $variation_min_reg_price = $product->get_variation_regular_price('min', true);     $variation_min_sale_price = $product->get_variation_sale_price('min', true);     if ( $product->is_on_sale() && !empty($variation_min_sale_price)){         if ( !empty($variation_min_sale_price) )             $price = '<del class="strike">' .  woocommerce_price($variation_min_reg_price) . '</del>         <ins class="highlight">' .  woocommerce_price($variation_min_sale_price) . '</ins>';     } else {         if(!empty($variation_min_reg_price))             $price = '<ins class="highlight">'.woocommerce_price( $variation_min_reg_price ).'</ins>';         else             $price = '<ins class="highlight">'.woocommerce_price( $product->regular_price ).'</ins>';     }     return $price; } 

the code goes in function.php file of active child theme (or theme) or in plugin file.

this code tested , works.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -