Skip to content

Commit 51c1072

Browse files
Merge pull request #119 from Paazl/release/1.17.6
Release/1.17.6
2 parents 438e8d2 + 09f0b15 commit 51c1072

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "paazl/magento2-checkout-widget",
33
"description": "Paazl checkoutWidget for Magento 2",
44
"type": "magento2-module",
5-
"version": "1.17.5",
5+
"version": "1.17.6",
66
"keywords": [
77
"Paazl",
88
"Magento 2",

etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<default>
99
<carriers>
1010
<paazlshipping>
11-
<version>v1.17.5</version>
11+
<version>v1.17.6</version>
1212
<active>0</active>
1313
<sallowspecific>0</sallowspecific>
1414
<price>0</price>

view/frontend/web/js/checkout/action/set-shipping-information-mixin.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ define([
6666
shippingAddress.firstname = currentAddress.firstname;
6767
shippingAddress.lastname = currentAddress.lastname;
6868
shippingAddress.countryId = currentAddress.country_id;
69-
shippingAddress.region = currentAddress.region;
69+
shippingAddress.region = typeof currentAddress.region === 'object' && currentAddress.region !== null
70+
? currentAddress.region.region
71+
: currentAddress.region;
7072
shippingAddress.city = currentAddress.city;
7173
shippingAddress.postcode = currentAddress.postcode;
7274
shippingAddress.street = Object.values(currentAddress.street);

view/frontend/web/js/checkout/view/shipping-mixin.js

+53-11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,22 @@ define([
1212
'Magento_Checkout/js/model/shipping-save-processor/payload-extender',
1313
'Magento_Checkout/js/model/resource-url-manager',
1414
'Magento_Checkout/js/model/error-processor',
15-
'Paazl_CheckoutWidget/js/checkout/view/widget-config'
16-
], function ($, _, ko, storage, quote, payloadExtender, resourceUrlManager, errorProcessor, widgetConfig) {
15+
'Paazl_CheckoutWidget/js/checkout/view/widget-config',
16+
'Magento_Customer/js/model/customer',
17+
'Paazl_CheckoutWidget/js/checkout/model/shipping-locations',
18+
], function (
19+
$,
20+
_,
21+
ko,
22+
storage,
23+
quote,
24+
payloadExtender,
25+
resourceUrlManager,
26+
errorProcessor,
27+
widgetConfig,
28+
customer,
29+
shippingLocations
30+
) {
1731
"use strict";
1832

1933
/**
@@ -78,25 +92,53 @@ define([
7892

7993
setShippingInformation: function () {
8094
const savedSelectedShippingAddress = quote.shippingAddress();
81-
let ajaxHandled = false;
8295

8396
widgetConfig.prototype.lock();
8497
this._super();
8598

8699
if (savedSelectedShippingAddress.customerAddressId !== quote.shippingAddress().customerAddressId) {
87-
quote.shippingAddress(savedSelectedShippingAddress);
88-
89-
$(document).ajaxComplete((_, xhr, settings) => {
90-
if (!ajaxHandled && settings.url.includes(resourceUrlManager.getUrlForSetShippingInformation(quote))) {
91-
ajaxHandled = true;
92-
this.saveShippingInformation();
93-
}
94-
});
100+
this.updateShippingInfo(savedSelectedShippingAddress);
101+
}
102+
103+
if (!shippingLocations.selectedLocationCode()) {
104+
const customerAddressId = quote.shippingAddress().customerAddressId;
105+
const customerAddressList = customer.customerData.addresses;
106+
107+
if (customerAddressList) {
108+
const currentAddress = customerAddressList[customerAddressId];
109+
const shippingAddress = Object.assign({}, quote.shippingAddress(), {
110+
firstname: currentAddress.firstname,
111+
lastname: currentAddress.lastname,
112+
countryId: currentAddress.country_id,
113+
region: typeof currentAddress.region === 'object' && currentAddress.region !== null
114+
? currentAddress.region.region
115+
: currentAddress.region,
116+
city: currentAddress.city,
117+
postcode: currentAddress.postcode,
118+
street: Object.values(currentAddress.street),
119+
telephone: currentAddress.telephone
120+
});
121+
122+
this.updateShippingInfo(shippingAddress);
123+
}
95124
}
96125

97126
widgetConfig.prototype.unlock();
98127
},
99128

129+
updateShippingInfo(address) {
130+
let ajaxHandled = false;
131+
132+
quote.shippingAddress(address);
133+
134+
$(document).ajaxComplete((_, xhr, settings) => {
135+
if (!ajaxHandled && settings.url.includes(resourceUrlManager.getUrlForSetShippingInformation(quote))) {
136+
ajaxHandled = true;
137+
this.saveShippingInformation();
138+
}
139+
});
140+
},
141+
100142
saveShippingInformation: function () {
101143
var payload;
102144

0 commit comments

Comments
 (0)