• In my WooCommerce settings, I have a number of decimals set to 0.
    On the product page, the discount calculated by JavaScript is correct.

    However, when I add a product to the cart, the discount price is wrong.

    Example
    discount rules: 30 – 39 | 5
    product value: 295.00
    quantity: 30

    Subtotal
    should be: 8408
    is: 8400

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jason Kytros

    (@jasonkytros)

    Hey there,

    Thanks for reaching out!

    Here’s how the discount is calculated in this case:
    1. A 5% discount is applied on the product’s price — the discounted product price is (295 * 95) / 100 = 280.25.
    2. All decimals are removed since you have set the number of decimals to 0 — the new discounted price is 280.
    3. This price is multiplied by the product’s quantity 280 * 30 = 8400.

    If you’d like the total price to be 8408, then please use the following snippet:

    add_filter( 'woocommerce_bundled_item_discounted_price_precision', 'sw_incr_wc_bundled_item_price_precision' );
    function sw_incr_wc_bundled_item_price_precision( $precision ) {
    	return 2;
    }
    

    If you are not certain how to use snippets like this, I’d suggest having a look at this plugin — you may find it quite useful as it allows you to manage all your snippets in one place.

    Does this help?

    Cheers,
    Jason Kytros
    Support Engineer | SomewhereWarm SMPC | https://somewherewarm.com/

    Thread Starter Rafal Sokolowski

    (@rafalsokolowski)

    Thanks for your reply. The snippet solves the problem.

    However, I’d say the plugin should be consistent. In my example, the discount calculated on the product page was 8408 but when I added the product bundle to the cart, it changed to 8400.

    It means JavaScript function applies the discount to a product bundle whereas the cart to each product.

    Plugin Author Jason Kytros

    (@jasonkytros)

    Hey @rafalsokolowski,

    Apologies for taking us so long to get back to you on this!

    I discussed your case in more detail with our Engineering team and we found an issue on our side that prevented Bundle prices from getting calculated/rounded correctly. We really appreciate taking the time to bring this to our attention!

    We have already resolved this issue and the fix is included in the latest Product Bundles version (v6.7.7) that is now available for download.

    After you download and install the latest Product Bundles version, you may remove the snippet I previously sent you.

    Can you please give this a try and let us know how this goes?

    Cheers,
    Jason Kytros
    Support Engineer | SomewhereWarm SMPC | https://somewherewarm.com/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Incorrect discount price on cart and checkout pages when no decimals’ is closed to new replies.