Skip to content

Commit 874c6b6

Browse files
AC-2044::Cart Price Rule with shipping method set as condition is not working Magento-fix unit tests failure
1 parent 85c1f73 commit 874c6b6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/quote.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
define([
99
'ko',
1010
'underscore',
11+
'Magento_Checkout/js/checkout-data',
1112
'domReady!'
12-
], function (ko, _) {
13+
], function (ko, _, checkoutData) {
1314
'use strict';
1415

1516
/**
@@ -148,6 +149,17 @@ define([
148149
*/
149150
isPersistent: function () {
150151
return !!Number(quoteData['is_persistent']);
152+
},
153+
154+
/**
155+
* @return {String|null}
156+
*/
157+
getSelectedMethod: function () {
158+
const selectedShippingMethod = checkoutData.getSelectedShippingRate();
159+
return selectedShippingMethod ? selectedShippingMethod :
160+
this.shippingMethod() ?
161+
this.shippingMethod()['carrier_code'] + '_' + quote.shippingMethod()['method_code'] :
162+
null;
151163
}
152164
};
153165
});

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ define([
7373
isNewAddressAdded: ko.observable(false),
7474
saveInAddressBook: 1,
7575
quoteIsVirtual: quote.isVirtual(),
76-
76+
selectedShippingRate: null,
7777
/**
7878
* @return {exports}
7979
*/
@@ -113,7 +113,7 @@ define([
113113

114114
registry.async('checkoutProvider')(function (checkoutProvider) {
115115
var shippingAddressData = checkoutData.getShippingAddressFromData();
116-
116+
this.selectedShippingRate = checkoutData.getSelectedShippingRate();
117117
if (shippingAddressData) {
118118
checkoutProvider.set(
119119
'shippingAddress',
@@ -259,11 +259,7 @@ define([
259259
rates: shippingService.getShippingRates(),
260260
isLoading: shippingService.isLoading,
261261
isSelected: ko.computed(function () {
262-
const selectedShippingMethod = checkoutData.getSelectedShippingRate();
263-
return selectedShippingMethod ? selectedShippingMethod :
264-
quote.shippingMethod() ?
265-
quote.shippingMethod()['carrier_code'] + '_' + quote.shippingMethod()['method_code'] :
266-
null;
262+
return quote.getSelectedMethod();
267263
}),
268264

269265
/**

0 commit comments

Comments
 (0)