0
我们使用以下代码显示类别页面产品和单个产品页面上的总百分比折扣。但是,该代码不显示任何输出。所以如果有人知道解决方案,请查看这段代码并帮助我。未显示总百分比折扣
add_filter('woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2);
function woocommerce_custom_sales_price($price, $product) {
$percentage = round((($product->regular_price - $product->sale_price)/$product->regular_price) * 100);
return $price . sprintf(__('<span class="percentage-dscnt"> %s Off</span>', 'woocommerce'), $percentage . '%');
}
感谢您的重播。但我需要像这样的百分比折扣 - > http://nimb.ws/meoza2 – Ketan
链接不工作 –
在这里工作 - >看到这个屏幕截图http://nimb.ws/meoza2 – Ketan