• Resolved Leo.Lin

    (@bi1012037)


    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>';
    }
    • This topic was modified 2 years, 9 months ago by Leo.Lin.
    • This topic was modified 2 years, 9 months ago by Leo.Lin.
Viewing 1 replies (of 1 total)
  • Thread Starter Leo.Lin

    (@bi1012037)

    /var/www/html/wordpress/wp-content/plugins/woocommerce/templates/loop/sale-flash.php

    <?php if ( $product->is_on_sale()) : ?>

    change to

    <?php if ( $product->is_on_sale()|| Original price != Discounted price) : ?>

    #Original price:$product->regular_price
    #Discounted price:Specify your own variables

Viewing 1 replies (of 1 total)
  • The topic ‘How to add sale tag?’ is closed to new replies.