Woocommerce只显示一个价格变化的产品打折

问题描述:

这里是我的WooCommerce网站:sweetworldcandy.comWoocommerce只显示一个价格变化的产品打折

的问题是,在可变产品价格最低,最大 值显示我想要的是,如果产品不出售显示至少值,如果它是在销售展示的最小值,并通过添加一个斜杠为删除标签

我分享下面这三张图片的参考报价价格的最低值:

enter image description hereif not on saleenter image description here

+0

代码在哪里? –

+0

我看了所有的主题我coudnet找到的具体钩在woocommerce – Shaik

下面的代码应该做你所期望的:

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; 
} 

的代码放在你的活跃儿童主题(或主题)的function.php文件或也以任何插件文件。

此代码已经过测试并可正常工作。

+0

感谢您的帮助,它现在工作很好 – Shaik

+0

woocommerce_variable_sale_price_html永远不会在我的情况下调用,任何建议为什么? –