|
6 | 6 | define(
|
7 | 7 | [
|
8 | 8 | 'ko',
|
9 |
| - 'jquery', |
10 | 9 | 'Magento_Checkout/js/model/quote',
|
11 | 10 | 'Magento_Checkout/js/model/resource-url-manager',
|
12 | 11 | 'mage/storage',
|
13 | 12 | 'Magento_Checkout/js/model/payment-service',
|
14 | 13 | 'Magento_Checkout/js/model/payment/method-converter',
|
15 | 14 | 'Magento_Checkout/js/model/error-processor',
|
16 |
| - 'Magento_Checkout/js/model/full-screen-loader' |
| 15 | + 'Magento_Checkout/js/model/full-screen-loader', |
| 16 | + 'Magento_Checkout/js/action/select-billing-address' |
17 | 17 | ],
|
18 | 18 | function (
|
19 | 19 | ko,
|
20 |
| - $, |
21 | 20 | quote,
|
22 | 21 | resourceUrlManager,
|
23 | 22 | storage,
|
24 | 23 | paymentService,
|
25 | 24 | methodConverter,
|
26 | 25 | errorProcessor,
|
27 |
| - fullScreenLoader |
| 26 | + fullScreenLoader, |
| 27 | + selectBillingAddressAction |
28 | 28 | ) {
|
29 | 29 | 'use strict';
|
| 30 | + |
30 | 31 | return {
|
31 |
| - saveShippingInformation: function() { |
32 |
| - var billingAddress = quote.billingAddress(); |
33 |
| - if (!billingAddress) { |
34 |
| - billingAddress = $.extend({}, quote.shippingAddress()); |
35 |
| - quote.billingAddress(billingAddress); |
36 |
| - quote.shippingAddress().sameAsBilling = 1; |
| 32 | + saveShippingInformation: function () { |
| 33 | + var payload; |
| 34 | + |
| 35 | + if (!quote.billingAddress()) { |
| 36 | + selectBillingAddressAction(quote.shippingAddress()); |
37 | 37 | }
|
38 |
| - var payload = { |
| 38 | + |
| 39 | + payload = { |
39 | 40 | addressInformation: {
|
40 | 41 | shipping_address: quote.shippingAddress(),
|
41 |
| - billing_address: billingAddress, |
| 42 | + billing_address: quote.billingAddress(), |
42 | 43 | shipping_method_code: quote.shippingMethod().method_code,
|
43 | 44 | shipping_carrier_code: quote.shippingMethod().carrier_code
|
44 | 45 | }
|
45 | 46 | };
|
46 | 47 |
|
47 | 48 | fullScreenLoader.startLoader();
|
| 49 | + |
48 | 50 | return storage.post(
|
49 | 51 | resourceUrlManager.getUrlForSetShippingInformation(quote),
|
50 | 52 | JSON.stringify(payload)
|
|
0 commit comments