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