Skip to content

Commit 55c5be4

Browse files
author
Ievgen Shakhsuvarov
committed
Merge branch '44444-save-twice' of github.corp.magento.com:magento-folks/magento2ce into bugs
2 parents 7535e65 + 25928c0 commit 55c5be4

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

app/code/Magento/Checkout/Api/Data/ShippingInformationInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ interface ShippingInformationInterface extends \Magento\Framework\Api\CustomAttr
1212
*/
1313
const SHIPPING_ADDRESS = 'shipping_address';
1414

15+
const BILLING_ADDRESS = 'billing_address';
16+
1517
const SHIPPING_METHOD_CODE = 'shipping_method_code';
1618

1719
const SHIPPING_CARRIER_CODE = 'shipping_carrier_code';
@@ -33,6 +35,21 @@ public function getShippingAddress();
3335
*/
3436
public function setShippingAddress(\Magento\Quote\Api\Data\AddressInterface $address);
3537

38+
/**
39+
* Returns billing address
40+
*
41+
* @return \Magento\Quote\Api\Data\AddressInterface|null
42+
*/
43+
public function getBillingAddress();
44+
45+
/**
46+
* Set billing address if additional synchronization needed
47+
*
48+
* @param \Magento\Quote\Api\Data\AddressInterface $address
49+
* @return $this
50+
*/
51+
public function setBillingAddress(\Magento\Quote\Api\Data\AddressInterface $address);
52+
3653
/**
3754
* Returns shipping method code
3855
*

app/code/Magento/Checkout/Model/ShippingInformation.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ public function setShippingAddress(\Magento\Quote\Api\Data\AddressInterface $add
2929
return $this->setData(self::SHIPPING_ADDRESS, $address);
3030
}
3131

32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function getBillingAddress()
36+
{
37+
return $this->getData(self::BILLING_ADDRESS);
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function setBillingAddress(\Magento\Quote\Api\Data\AddressInterface $address)
44+
{
45+
return $this->setData(self::BILLING_ADDRESS, $address);
46+
}
47+
3248
/**
3349
* {@inheritdoc}
3450
*/

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public function saveAddressInformation(
128128
$addressData = $this->addressRepository->getById($customerAddressId);
129129
$address = $quote->getShippingAddress()->importCustomerAddressData($addressData);
130130
}
131+
$billingAddress = $addressInformation->getBillingAddress();
132+
if ($billingAddress) {
133+
$quote->setBillingAddress($billingAddress);
134+
}
131135

132136
$address->setSaveInAddressBook($saveInAddressBook);
133137
$address->setSameAsBilling($sameAsBilling);

app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ define([
172172
}
173173
},
174174
applyBillingAddress: function () {
175+
if (quote.billingAddress()) {
176+
selectBillingAddress(quote.billingAddress());
177+
return;
178+
}
175179
var shippingAddress = quote.shippingAddress();
176180
if (shippingAddress
177181
&& shippingAddress.canUseForBilling()

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor/default.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ define(
2727
'use strict';
2828
return {
2929
saveShippingInformation: function() {
30+
var billingAddress = quote.billingAddress() || quote.shippingAddress();
3031
var payload = {
3132
addressInformation: {
3233
shipping_address: quote.shippingAddress(),
34+
billing_address: billingAddress,
3335
shipping_method_code: quote.shippingMethod().method_code,
3436
shipping_carrier_code: quote.shippingMethod().carrier_code
3537
}

0 commit comments

Comments
 (0)