Skip to content

Commit

Permalink
set shipping information without messing with billing addressses
Browse files Browse the repository at this point in the history
Mostly a copy of shipping-save-processor/default.js, with the parts
relating to billing addresses removed, as it's not relevant for
calculating shipping costs.

Closes #15.
  • Loading branch information
danslo committed Jan 24, 2018
1 parent 777832c commit 28b6143
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/view/frontend/web/js/mixin/select-shipping-method-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* See LICENSE.txt for license details.
*/
define([
'Magento_Checkout/js/action/set-shipping-information'
], function (setShippingInformationAction) {
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/resource-url-manager',
'mage/storage',
'Magento_Checkout/js/model/full-screen-loader'
], function (quote, resourceUrlManager, storage, fullScreenLoader) {
'use strict';

/**
Expand All @@ -13,7 +16,30 @@ define([
return function (target) {
return function (shippingMethod) {
target(shippingMethod);
setShippingInformationAction();

var payload = {
addressInformation: {
'shipping_address': quote.shippingAddress(),
'shipping_method_code': quote.shippingMethod()['method_code'],
'shipping_carrier_code': quote.shippingMethod()['carrier_code']
}
};

fullScreenLoader.startLoader();

return storage.post(
resourceUrlManager.getUrlForSetShippingInformation(quote),
JSON.stringify(payload)
).done(
function (response) {
quote.setTotals(response.totals);
fullScreenLoader.stopLoader();
}
).fail(
function () {
fullScreenLoader.stopLoader();
}
);
};
}
});

0 comments on commit 28b6143

Please sign in to comment.