Home Forums WoodMart support forum Duplicate percentage tag

Duplicate percentage tag

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #563914

    admin-1492
    Participant

    Hi there,
    The % sale tag on products is duplicate on my products page. I guess I need to turn off some option but don’t know where to find it. Please check ТопМатрак
    I want to remove the background tag and leave only one %.
    Thank you

    #564071

    Hung Pham
    Keymaster

    Hi admin-1492,

    Thanks for reaching to us.

    You should deactivate all plugins (except Required Plugins) and then reactivate them one by one. This makes it very easy to isolate the plugin causing problems.

    Regards,

    #564432

    admin-1492
    Participant

    Hi there,
    I fixed the problem. I’ve added that additional php through Code Snippets which was causing the problem.
    I’ve deleted this code and the problem is fixed. Thank.
    Regards

    add_action( ‘woocommerce_sale_flash’, ‘sale_badge_percentage’, 25 );

    function sale_badge_percentage() {
    global $product;
    if ( ! $product->is_on_sale() ) return;
    if ( $product->is_type( ‘simple’ ) ) {
    $max_percentage = ( ( $product->get_regular_price() – $product->get_sale_price() ) / $product->get_regular_price() ) * 100;
    } elseif ( $product->is_type( ‘variable’ ) ) {
    $max_percentage = 0;
    foreach ( $product->get_children() as $child_id ) {
    $variation = wc_get_product( $child_id );
    $price = $variation->get_regular_price();
    $sale = $variation->get_sale_price();
    if ( $price != 0 && ! empty( $sale ) ) $percentage = ( $price – $sale ) / $price * 100;
    if ( $percentage > $max_percentage ) {
    $max_percentage = $percentage;
    }
    }
    }
    if ( $max_percentage > 0 ) echo “<span class=’onsale’>-” . round($max_percentage) . “%</span>”; // If you would like to show -40% off then add text after % sign
    }

    #564571

    Hung Pham
    Keymaster

    Hi admin-1492,

    Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!

    Regards,

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Duplicate percentage tag’ is closed to new replies.