Skip to content

Commit 4c3280b

Browse files
MC-34793: Coupon code based on shipping method remains applied after shipping method changed to another one
1 parent 29e1368 commit 4c3280b

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

app/code/Magento/SalesRule/view/frontend/requirejs-config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var config = {
88
mixins: {
99
'Magento_Checkout/js/action/select-payment-method': {
1010
'Magento_SalesRule/js/action/select-payment-method-mixin': true
11+
},
12+
'Magento_Checkout/js/model/shipping-save-processor': {
13+
'Magento_SalesRule/js/model/shipping-save-processor-mixin': true
1114
}
1215
}
1316
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'mage/utils/wrapper',
7+
'Magento_Checkout/js/model/quote',
8+
'Magento_SalesRule/js/model/coupon'
9+
], function (wrapper, quote, coupon) {
10+
'use strict';
11+
12+
return function (shippingSaveProcessor) {
13+
shippingSaveProcessor.saveShippingInformation = wrapper.wrapSuper(
14+
shippingSaveProcessor.saveShippingInformation,
15+
function (type) {
16+
var updateCouponCallback;
17+
18+
/**
19+
* Update coupon form
20+
*/
21+
updateCouponCallback = function () {
22+
if (quote.totals() && !quote.totals()['coupon_code']) {
23+
coupon.setCouponCode('');
24+
coupon.setIsApplied(false);
25+
}
26+
};
27+
28+
return this._super(type).done(updateCouponCallback);
29+
}
30+
);
31+
32+
return shippingSaveProcessor;
33+
};
34+
});

0 commit comments

Comments
 (0)