• Resolved awbildner

    (@awbildner)


    Hi, we’re experiencing rounding errors with the API when transferring orders to another system. Orders in the database contain the correct tax amount with multiple decimal places. However, the API rounds this value to two decimal places. This causes rounding errors and incorrect amounts in the other system.

    Example order with ID xxx in table wc_order_product_lookup, column tax_amount shows: 1.354545

    When retrieving the same order from the API via /wp-json/wc/v3/orders/xxx, the values ​​for subtotal_tax and total_tax are only: 1.35

    Is this rounding intentional? And can I change this somewhere? We need the exact value with six decimal places from the API, exactly as it’s stored in the database.

    Best regards, Anja

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thank you for sharing the details and examples.

    The behavior you’re seeing is expected in WooCommerce REST API. By default, the API rounds tax and totals to two decimal places when returning order data. This is done to align with standard currency formatting for most payment gateways and financial reporting. For more details you can use this guide. https://woocommerce.github.io/woocommerce-rest-api-docs/#request-response-format

    Currently, there is no built-in option in WooCommerce to return more than two decimal places via the REST API. The values in the database may have more precision, but the API rounds them before output.

    If you need more in-depth support or want to consider professional assistance for customization, I can recommend WooExperts and Codeable.io as options for getting professional help. Alternatively, you can also ask your development questions in the  WooCommerce Community Slack as custom code falls outside our usual scope of support.

    Thread Starter awbildner

    (@awbildner)

    Thanks for the quick reply, that was helpful!

    I’ve looked into it, and it should be solvable with the information from your link to the guide using the parameter dp=6.

    I’ll pass this info on to the developers of our external ordering system.

    Have a nice day!

    Hi @awbildner,

    Glad to hear that helped and that you were able to resolve it using the dp parameter.

    If WooCommerce has been useful for your store and you appreciate the support you received here, we’d really appreciate it if you could leave a quick review:
    https://ww.wp.xz.cn/support/plugin/woocommerce/reviews/#new-post

    Feel free to open a new topic if you need anything else. Have a great day!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.