• Resolved adrianpajares

    (@adrianpajares)


    Hi,

    We have a problem with calculations. (Tested in a new instance with only WC)

    Example: Configuration -> 2 decimals // a product with price 2,128 * 48 = 102,44 but if you have 2 decimals, the price shows 2,13 but the total shows the same 102,44 and should be 2,13*48=102,24

    Any solutions? Thanks in advice!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @adrianpajares

    Thanks for reaching out!

    Based on your example here: 2,128 * 48 = 102,44, the correct answer should be 102,144.

    Can you please provide further details on your issue here so that we could check this further?

    If a screenshot would be helpful, I’d recommend using https://snipboard.io or https://skitch.com/. You can share the direct link to the image as a response to this topic.

    Thanks!

    Thread Starter adrianpajares

    (@adrianpajares)

    This is the configuration.

    The product:

    Cart:

    Is possible to only do calculation operations with only 2 decimals?

    Thanks,

    Howdy @adrianpajares

    Thank you for reaching back, sharing more details on this.

    From what I gather, while under the “Opciones de moneda” a two-digit decimal is selected, subsequently the prices are entered using three decimals. Why is that?

    I suggest opting for either two digits, or three, for both the option under “Opciones de moneda” and the product prices.

    Let us know how that goes.

    Thread Starter adrianpajares

    (@adrianpajares)

    The reason is because sometimes the price is imported or is applied a discount.

    If you use a plugin (I tested several plugins) the calculation is the same, example:

    Applied a 5% of discount:

    Any calculation, discounts, taxes, prices introduced with multiple decimals… should be calculated with only 2 decimals if I select it.

    Saif

    (@babylon1999)

    Hello @adrianpajares,

    The 2 decimal points you change from WooCommerce settings have nothing to do with the calculation, it’s how the price will be rendered in the front end.


    Link to image: https://d.pr/i/Z4GohL


    From my understanding of what you’re trying to achieve, you’ll need to work with the woocommerce_get_price hook.

    You can add the following to your functions.php file.

    function round_price($price, $product) {
      return wc_format_decimal($price, 2);
    }
    add_filter('woocommerce_get_price', 'round_price', 10, 2);
    


    Link to image: https://d.pr/i/qJTK6z

    I trust this clears up the confusion, please note that we are not developers here so if you need more help with customizations you can hire a WooExpert.

    Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Decimal Error Calculation’ is closed to new replies.