@@ -65,9 +65,10 @@ define([
65
65
} ) ;
66
66
67
67
var parcelshop = sessionStorage . getItem ( 'selectedParcelshop' ) ;
68
- if ( parcelshop ) {
68
+ if ( parcelshop && JSON . parse ( parcelshop ) . isoAlpha2 === quote . shippingAddress ( ) . countryId ) {
69
69
this . selectParcelShop ( JSON . parse ( parcelshop ) ) ;
70
70
} else {
71
+ sessionStorage . removeItem ( 'selectedParcelshop' ) ;
71
72
this . showMap ( ) ;
72
73
}
73
74
}
@@ -129,23 +130,30 @@ define([
129
130
sessionStorage . setItem ( 'selectedParcelshop' , JSON . stringify ( parcelshop ) ) ;
130
131
window . dpdShippingAddress = parcelshop ;
131
132
132
- var options = {
133
- method : 'POST' ,
134
- showLoader : true ,
135
- url : window . checkoutConfig . dpd_parcelshop_save_url ,
136
- data : parcelshop
137
- } ;
138
-
139
- $ . ajax ( options ) . done ( ( response ) => {
140
- $ ( '#dpd-connect-selected-container' ) . html ( response ) ;
141
-
142
- $ ( '#dpd_company' ) . html ( parcelshop . company ) ;
143
- $ ( '#dpd_street' ) . html ( parcelshop . street + ' ' + parcelshop . houseNo ) ;
144
- $ ( '#dpd_zipcode_and_city' ) . html ( parcelshop . zipCode + ' ' + parcelshop . city ) ;
145
- $ ( '#dpd_country' ) . html ( parcelshop . isoAlpha2 ) ;
146
- $ ( '.dpd-shipping-information' ) . show ( ) ;
147
- $ ( '#dpd-connect-selected-container' ) . show ( ) ;
148
- } ) ;
133
+ if ( parcelshop . isoAlpha2 === quote . shippingAddress ( ) . countryId ) {
134
+ var options = {
135
+ method : 'POST' ,
136
+ showLoader : true ,
137
+ url : window . checkoutConfig . dpd_parcelshop_save_url ,
138
+ data : parcelshop
139
+ } ;
140
+
141
+ $ . ajax ( options ) . done ( ( response ) => {
142
+ $ ( '#dpd-connect-selected-container' ) . html ( response ) ;
143
+
144
+ $ ( '#dpd_company' ) . html ( parcelshop . company ) ;
145
+ $ ( '#dpd_street' ) . html ( parcelshop . street + ' ' + parcelshop . houseNo ) ;
146
+ $ ( '#dpd_zipcode_and_city' ) . html ( parcelshop . zipCode + ' ' + parcelshop . city ) ;
147
+ $ ( '#dpd_country' ) . html ( parcelshop . isoAlpha2 ) ;
148
+ $ ( '.dpd-shipping-information' ) . show ( ) ;
149
+ $ ( '#dpd-connect-selected-container' ) . show ( ) ;
150
+ } ) ;
151
+ } else {
152
+ sessionStorage . removeItem ( 'selectedParcelshop' ) ;
153
+ $ ( '#dpd-connect-map-container' ) . html ( $ . mage . __ ( 'Country of selected parcel shop is not equal to selected country. Please enter a valid address and try again.' ) ) ;
154
+ $ ( '#dpd-connect-map-container' ) . show ( ) ;
155
+ this . showMap ( ) ;
156
+ }
149
157
}
150
158
} ) ;
151
159
} ) ;
0 commit comments