Skip to content

Commit

Permalink
Merge branch 'bugfix/handle-currency-formatting' into release-week-42
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Oct 16, 2023
2 parents 5373ffe + 3ad2148 commit 07659b7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions view/frontend/web/js/view/product/apple-pay-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ define([
},

getProductPrice: function () {
return $('[data-role=priceBox][data-product-id] [data-price-type="finalPrice"] .price')
var price = $('[data-role=priceBox][data-product-id] [data-price-type="finalPrice"] .price')
.html()
.replace(/[^\d,.-]/g, '')
.replace(',', '.');
.replace(/[^\d,.-]/g, '');

// We get the price formatted as in the currency, eg 1.000,00 or 1,000.00. So remove all dots and
// commas and divide by 100 to get the price in cents.
return (price.replace(',', '').replace('.', '') / 100).toFixed(2);
},

createApplePaySession: function () {
Expand Down

0 comments on commit 07659b7

Please sign in to comment.