-
Notifications
You must be signed in to change notification settings - Fork 69
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: pricing decimal formatting for tokenized cart #8992
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: +47 B (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
export const transformPrice = ( price, priceObject ) => | ||
// making sure the decimals are always correctly represented for GooglePay/ApplePay, since they don't allow us to specify the decimals. | ||
price * 10 ** ( 2 - priceObject.currency_minor_unit ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is similar to this formatting function: https://github.com/woocommerce/woocommerce/blob/e5fafb455eded795d66ae0f75b2cc8a3a36320ca/plugins/woocommerce-blocks/assets/js/extensions/google-analytics/utils.ts#L59
instead of ({price} / 10^{currency_minor_unit}) * 100
, it's simplified to {price} * 10 ^ (2 - {currency_minor_unit})
, because 100
==10^2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well with various currencies and decimal places. The changes all make sense as well. 🚢
I do have one question that's not really part of this PR. What's the cartData.totals.total_refund
that's being subtracted from each amount
? Is there some flow a shopper could reach that allows the use of a refund? Just curious really and wasn't able to find this in the original PRB implementation.
In the pay-for-order flow, an order can be created & subsequently updated with refunded amounts (all while the order is still "pending payment"). We have a WooPayments-wide issue I created about this: #8933 |
Fixes partially #8373
Changes proposed in this Pull Request
The store's currency number of decimals are not taken into account when providing the data to GooglePay/ApplePay.
We need to ensure we're providing cents to the GooglePay/ApplePay API.
Fixing.
Before:
After:
Testing instructions
2
to0
(for example - you could also try1
)npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge