Home Forums Theme Support Dokan How to remove the dashed discount price?

This topic is: resolved

This topic contains 5 replies, has 3 voices, and was last updated by  abelljefrry 4 years, 12 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #19408

    abelljefrry
    Member
    Post count: 23

    Hello Wedevs Team,

    May I know how to remove the dashed discount price? Because it makes the price text longer and forced the cart button outside of the product thumbnail/tiles. Imagine if our user post a $XXXX.XX products, or even worst it's on sale. That would be a total disaster to Dokan theme layout.

    This issue can be seen in Dokan demo too, here's the screenshot:

    View post on imgur.com

    View post on imgur.com

    Plus, I'm using the smart sale badge plugin, so it's OK for me to remove the before discount price.
    https://wordpress.org/plugins/woocommerce-smart-sale-badge/screenshots/

    #19436

    Nizam Uddin
    Keymaster
    Post count: 670

    Hello
    Thanks for pointing it out. I will forward it to our development team. Thank you..

    #19532

    Sk
    Moderator
    Post count: 371

    Please write the following code to your function.php file to remove dashed discount price.

    add_filter( 'woocommerce_variable_sale_price_html', function($html, $product) {
    
        $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
        $price = $prices[0] !== $prices[1] ? sprintf( _x( '%1$s–%2$s', 'Price range: from-to', 'woocommerce' ), wc_price( $prices[0] ), wc_price( $prices[1] ) ) : wc_price( $prices[0] );
    
        return $price;
    
        return $html;
    }, 10 ,2 );

    thank you.

    #19593

    abelljefrry
    Member
    Post count: 23

    Hello Nizam & Shaikat,

    Thanks for your great response.

    I've tried the code given above, it works great but it only remove the original price range (before discount) for variable products.

    Can you provide me a code to remove the striked/dashed original price for simple products? I mean like this one:

    View post on imgur.com

    #19619

    Sk
    Moderator
    Post count: 371

    Hello abelljefrry,

    We have found the same ๐Ÿ˜›

    Here the code for remove striked/dashed original price for simple products :

    add_filter( 'woocommerce_sale_price_html', function($price, $product){
    
        $tax_display_mode      = get_option( 'woocommerce_tax_display_shop' );
        $display_price         = $tax_display_mode == 'incl' ? $product->get_price_including_tax() : $product->get_price_excluding_tax();
    
        $price = wc_price( $display_price ) . $product->get_price_suffix();
        
        return $price;
    
    }, 10 ,2 );

    put this code at the bottom of the previous one.

    Thank you.

    #19622

    abelljefrry
    Member
    Post count: 23

    Hello Shaikat,

    It works! Thanks a lot! You guys are awesome! ๐Ÿ™‚

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

The topic ‘How to remove the dashed discount price?’ is closed to new replies.