Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Rounding-Issues with shipping costs and refunds #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

samuelmente
Copy link

We had an issue, where an unrounded amount for shipping was sent to Payone API resulting in an error. Woocommerce seems to be returning a rounded number for "shipping_total" but an unrounded amount for "shipping_tax" resulting in a false amount when adding. Adding round() will prevent this issue from causing problems.
Example: 1,95 shipping cost will falsely be sent to the API as 195.1345.

We had an issue, where an unrounded amount for shipping was sent to Payone API resulting in an error.
Woocommerce seems to be returning a rounded number for "shipping_total" but an unrounded amount for "shipping_tax" resulting in a false amount when adding.
Adding round() will prevent this issue from causing problems.
@janteuber
Copy link
Contributor

The change from the PR does make sense as it is. The round() function is indeed already used in other places. I would only modify the line like this:

'pr' =\> (int) round( 100 \* ( $refund_data\['shipping_total'\] + $refund_data\['shipping_tax'\] ) ),

This is because the return value of round() is a float, but we also want to ensure that it is an int.

@samuelmente
Copy link
Author

You are right. I added a change to include the int declaration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants