Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions view/frontend/web/js/button-config-platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ define(
* @returns {button-config-platformL#18.button-config-platformAnonym$1}
*/
function($, fullScreenLoader, quote, checkout, alert) {

return {
config: undefined,
wasSetup: false,
/*
* Fix issue in Magento < 2.6.0 where grand_total and base_grand_total don't match when using taxes or other extensions
* grand_total is the total in selected currency, base_grand_total is in store's default currency
* Continue to use grand_total for multi-currency setups
*/
getTotal: function () {
let totals = quote.getTotals()._latestValue;
let grandTotal = totals.base_grand_total;
if (totals.quote_currency_code !== totals.base_currency_code) {
grandTotal = totals.grand_total;
}
return grandTotal;
},

configure: function(data, context) {
document.logBreadIssue = function(level, issue) {
Expand All @@ -43,7 +55,7 @@ define(
}
};
this.config = {
customTotal: this.round(quote.getTotals()._latestValue.grand_total),
customTotal: this.round(this.getTotal()),
buttonLocation: window.checkoutConfig.payment.breadcheckout.breadConfig.buttonLocation,

//Bread SDK API onCheckout callback
Expand Down Expand Up @@ -223,7 +235,7 @@ define(
cb();
} else */
if (typeof this.config.shippingOptions === "undefined" && quote.isVirtual()) {
this.config.customTotal = this.round(quote.getTotals()._latestValue.grand_total);
this.config.customTotal = this.round(this.getTotal());
cb();
} else {
/* ocs save selected shipping method */
Expand All @@ -235,7 +247,7 @@ define(
}).done(
function(data) {
self.config.shippingOptions = [data];
self.config.customTotal = self.round(quote.getTotals()._latestValue.grand_total);
self.config.customTotal = self.round(this.getTotal());
cb();
}
).fail(
Expand Down Expand Up @@ -268,7 +280,7 @@ define(
"Discount";
}
/* this is needed if coupon is removed to update total price */
this.config.customTotal = this.round(quote.getTotals()._latestValue.grand_total);
this.config.customTotal = this.round(this.getTotal());
},
/**
* Get updated quote data and initialize
Expand Down