How to add sale tag?
-
Parameter Description:
Test A
Original Price:1000
Discounted Price:990
Test B
Original Price:1000
Vip Customer:1% off
There is no discount price for TestB products, and the plugin sets a discount of 1%, so the sale tag will not be displayed. How do I get started?
Sale tag Code
add_filter('woocommerce_sale_flash', 'mxp_custom_sale_flash', 10, 3); function mxp_custom_sale_flash($text, $post, $product) { global $product; $percentage = round((($product->regular_price - $product->sale_price) / $product->regular_price) * 100); return '<span class="onsale">' . $percentage . '% off</span>'; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add sale tag?’ is closed to new replies.