Skip to content

Commit 9e655c7

Browse files
author
Ievgen Shakhsuvarov
committed
MAGETWO-37889: Impossible to place order with Fedex as shipping method
1 parent 2f09fad commit 9e655c7

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ define(
2121
"paymentMethod": methodData
2222
};
2323

24-
var shippingMethodCode = quote.getSelectedShippingMethod()().split("_"),
24+
var shippingMethodCode = quote.getSelectedShippingMethod()().slice(0).split("_"),
2525
shippingMethodData = {
26-
"shippingCarrierCode" : shippingMethodCode[0],
27-
"shippingMethodCode" : shippingMethodCode[1]
26+
"shippingCarrierCode" : shippingMethodCode.shift(),
27+
"shippingMethodCode" : shippingMethodCode.join('_')
2828
},
2929
serviceUrl;
3030
if (quote.getCheckoutMethod()() === 'guest') {

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-service.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* Copyright © 2015 Magento. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
/*jshint browser:true jquery:true*/
6-
/*global alert*/
5+
/*global define*/
76
define(
87
['ko', 'jquery'],
98
function (ko, $) {
9+
"use strict";
1010
var rates = ko.observable([]);
1111
return {
1212
shippingRates: ko.observableArray([]),
@@ -30,29 +30,34 @@ define(
3030
return this.shippingRates;
3131
},
3232
getTitleByCode: function(methodCodeParts) {
33-
var shippingMethodTitle = '';
34-
if (methodCodeParts) {
35-
$.each(rates(), function (key, entity) {
36-
if (entity['carrier_code'] == methodCodeParts[0]
37-
&& entity['method_code'] == methodCodeParts[1]) {
38-
shippingMethodTitle = entity['carrier_title'] + " - " + entity['method_title'];
39-
}
40-
});
33+
var shippingMethodTitle = '', shippingMethodCode, carrierCode, methodCode;
34+
if (!methodCodeParts) {
35+
return shippingMethodTitle;
4136
}
37+
shippingMethodCode = methodCodeParts.slice(0);
38+
carrierCode = shippingMethodCode.shift();
39+
methodCode = shippingMethodCode.join('_');
40+
$.each(rates(), function (key, entity) {
41+
if (entity['carrier_code'] === carrierCode && entity['method_code'] === methodCode) {
42+
shippingMethodTitle = entity['carrier_title'] + " - " + entity['method_title'];
43+
}
44+
});
4245
return shippingMethodTitle;
4346
},
4447
getRateByCode : function(methodCodeParts) {
45-
var shippingRates = [];
48+
var shippingRates = [],
49+
shippingMethodCode = methodCodeParts.slice(0),
50+
carrierCode = shippingMethodCode.shift(),
51+
methodCode = shippingMethodCode.join('_');
4652
if (methodCodeParts) {
4753
$.each(rates(), function (key, entity) {
48-
if (entity['carrier_code'] == methodCodeParts[0]
49-
&& entity['method_code'] == methodCodeParts[1]) {
54+
if (entity['carrier_code'] === carrierCode && entity['method_code'] === methodCode) {
5055
shippingRates.push(entity);
5156
}
5257
});
5358
}
5459
return shippingRates;
5560
}
56-
}
61+
};
5762
}
5863
);

0 commit comments

Comments
 (0)