-
Notifications
You must be signed in to change notification settings - Fork 4
/
m2-one-step-checkout-v2.4.3-v2.4.4-patch.sh
345 lines (330 loc) · 13.2 KB
/
m2-one-step-checkout-v2.4.3-v2.4.4-patch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php
index 6aeaede..c0920d8 100644
--- a/Block/Checkout/LayoutProcessor.php
+++ b/Block/Checkout/LayoutProcessor.php
@@ -210,12 +210,6 @@ class LayoutProcessor implements LayoutProcessorInterface
$fields
);
- foreach ($fields as $code => &$field) {
- if(isset($field['label'])) {
- $field['label'] = __($field['label']);
- }
- }
-
return $this;
}
diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php
index 6bfb8cc..8475e59 100644
--- a/Controller/Index/Index.php
+++ b/Controller/Index/Index.php
@@ -73,18 +73,21 @@ class Index extends Onepage
public function initDefaultMethods($quote)
{
$shippingAddress = $quote->getShippingAddress();
-
- $defaultCountryId = $this->getDefaultCountryFromLocale();
if (!$shippingAddress->getCountryId()) {
- /** Get default country id from Geo Ip or Locale */
- $geoIpData = $this->_checkoutHelper->getAddressHelper()->getGeoIpData();
- if (!empty($geoIpData)) {
- $defaultCountryId = $geoIpData['country_id'];
- } elseif (!empty($this->_checkoutHelper->getDefaultCountryId())) {
+ if (!empty($this->_checkoutHelper->getDefaultCountryId())) {
$defaultCountryId = $this->_checkoutHelper->getDefaultCountryId();
+ } else {
+ /** Get default country id from Geo Ip or Locale */
+ $geoIpData = $this->_checkoutHelper->getAddressHelper()->getGeoIpData();
+ if (empty($geoIpData)) {
+ $defaultCountryId = $geoIpData['country_id'];
+ } else {
+ $defaultCountryId = $this->getDefaultCountryFromLocale();
+ }
}
$shippingAddress->setCountryId($defaultCountryId)->setCollectShippingRates(true);
}
+
$method = null;
try {
diff --git a/Helper/Address.php b/Helper/Address.php
index 542c13f..4482bce 100644
--- a/Helper/Address.php
+++ b/Helper/Address.php
@@ -303,14 +303,10 @@ class Address extends Data
$geoIpData['region'] = $record->mostSpecificSubdivision->name;
}
}
- $allowedCountries = $this->getConfigValue('general/country/allow');
- $allowedCountries = explode(',',$allowedCountries);
- if(!in_array($geoIpData['country_id'], $allowedCountries)){
- $geoIpData = [];
- }
} catch (\Exception $e) {
$geoIpData = [];
}
+
return $geoIpData;
}
diff --git a/Model/Plugin/Customer/AccountManagement.php b/Model/Plugin/Customer/AccountManagement.php
deleted file mode 100644
index 1656828..0000000
--- a/Model/Plugin/Customer/AccountManagement.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * Mageplaza
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Mageplaza.com license that is
- * available through the world-wide-web at this URL:
- * https://www.mageplaza.com/LICENSE.txt
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this extension to newer
- * version in the future.
- *
- * @category Mageplaza
- * @package Mageplaza_Osc
- * @copyright Copyright (c) 2017-2018 Mageplaza (http://www.mageplaza.com/)
- * @license https://www.mageplaza.com/LICENSE.txt
- */
-
-namespace Mageplaza\Osc\Model\Plugin\Customer;
-
-use Magento\Checkout\Model\Session;
-use Magento\Customer\Api\Data\CustomerInterface;
-use Magento\Customer\Model\AccountManagement as AM;
-
-/**
- * Class Address
- * @package Mageplaza\Osc\Model\Plugin\Customer
- */
-class AccountManagement
-{
- /**
- * @var Session
- */
- protected $checkoutSession;
-
- /**
- * AccountManagement constructor.
- * @param Session $checkoutSession
- */
- public function __construct(Session $checkoutSession)
- {
- $this->checkoutSession = $checkoutSession;
- }
-
- /**
- * @param AM $subject
- * @param mixed $password
- * @param mixed $redirectUrl
- * @return mixed
- */
- public function beforeCreateAccount(AM $subject, CustomerInterface $customer, $password = null, $redirectUrl = '')
- {
- $oscData = $this->checkoutSession->getOscData();
- if (isset($oscData['register']) && $oscData['register'] && isset($oscData['password']) && $oscData['password']) {
- $password = $oscData['password'];
-
- return [$customer, $password, $redirectUrl];
- }
- }
-}
diff --git a/Observer/QuoteSubmitSuccess.php b/Observer/QuoteSubmitSuccess.php
index bb832f5..82b7ad5 100644
--- a/Observer/QuoteSubmitSuccess.php
+++ b/Observer/QuoteSubmitSuccess.php
@@ -33,7 +33,6 @@ use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
use Magento\Newsletter\Model\SubscriberFactory;
-use Magento\Sales\Model\Order\CustomerManagement;
/**
* Class QuoteSubmitSuccess
@@ -72,18 +71,12 @@ class QuoteSubmitSuccess implements ObserverInterface
protected $subscriberFactory;
/**
- * @type CustomerManagement
- */
- protected $customerManagement;
-
- /**
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Customer\Api\AccountManagementInterface $accountManagement
* @param \Magento\Customer\Model\Url $customerUrl
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
- * @param CustomerManagement $subscriberFactory
*/
public function __construct(
Session $checkoutSession,
@@ -91,8 +84,7 @@ class QuoteSubmitSuccess implements ObserverInterface
Url $customerUrl,
ManagerInterface $messageManager,
CustomerSession $customerSession,
- SubscriberFactory $subscriberFactory,
- CustomerManagement $customerManagement
+ SubscriberFactory $subscriberFactory
)
{
$this->checkoutSession = $checkoutSession;
@@ -101,7 +93,6 @@ class QuoteSubmitSuccess implements ObserverInterface
$this->messageManager = $messageManager;
$this->_customerSession = $customerSession;
$this->subscriberFactory = $subscriberFactory;
- $this->customerManagement = $customerManagement;
}
/**
@@ -112,13 +103,12 @@ class QuoteSubmitSuccess implements ObserverInterface
{
/** @type \Magento\Quote\Model\Quote $quote $quote */
$quote = $observer->getEvent()->getQuote();
- $order = $observer->getEvent()->getOrder();
$oscData = $this->checkoutSession->getOscData();
if (isset($oscData['register']) && $oscData['register']
&& isset($oscData['password']) && $oscData['password']
) {
- $customer = $this->customerManagement->create($order->getId());
+ $customer = $quote->getCustomer();
/* Set customer Id for address */
if ($customer->getId()) {
diff --git a/composer.json b/composer.json
index 963abf3..75e85d4 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"geoip2/geoip2": "~2.0"
},
"type": "magento2-module",
- "version": "2.4.4",
+ "version": "2.4.3",
"license": "proprietary",
"authors": [
{
diff --git a/etc/di.xml b/etc/di.xml
index 49e5f0e..ac66390 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -31,10 +31,7 @@
<type name="Magento\Quote\Model\Cart\TotalsConverter">
<plugin name="addGiftWrapInitialAmount" type="Mageplaza\Osc\Model\Plugin\Quote\GiftWrap"/>
</type>
- <!-- <type name="Magento\Quote\Model\QuoteManagement">
+ <type name="Magento\Quote\Model\QuoteManagement">
<plugin name="mz_osc_quotemanagement" type="Mageplaza\Osc\Model\Plugin\Quote\QuoteManagement"/>
- </type> -->
- <type name="Magento\Customer\Model\AccountManagement">
- <plugin name="mz_osc_newaccount" type="Mageplaza\Osc\Model\Plugin\Customer\AccountManagement"/>
</type>
</config>
diff --git a/view/frontend/web/js/view/billing-address.js b/view/frontend/web/js/view/billing-address.js
index b72c67f..4ac876e 100644
--- a/view/frontend/web/js/view/billing-address.js
+++ b/view/frontend/web/js/view/billing-address.js
@@ -268,25 +268,6 @@ define(
this.source.trigger('billingAddress.custom_attributes.data.validate');
}
- if (this.source.get('params.invalid')) {
- var offsetHeight = $(window).height()/2,
- errorMsgSelector = $('#billing-new-address-form .mage-error:first').closest('.field');
-
- if (errorMsgSelector.length) {
- if (errorMsgSelector.find('select').length) {
- $('html, body').scrollTop(
- errorMsgSelector.find('select').offset().top - offsetHeight
- );
- errorMsgSelector.find('select').focus();
- } else if (errorMsgSelector.find('input').length) {
- $('html, body').scrollTop(
- errorMsgSelector.find('input').offset().top - offsetHeight
- );
- errorMsgSelector.find('input').focus();
- }
- }
- }
-
oscData.setData('same_as_shipping', false);
return !this.source.get('params.invalid');
},
diff --git a/view/frontend/web/js/view/form/element/email.js b/view/frontend/web/js/view/form/element/email.js
index 1c8dba3..13489f7 100644
--- a/view/frontend/web/js/view/form/element/email.js
+++ b/view/frontend/web/js/view/form/element/email.js
@@ -147,10 +147,6 @@ define([
if (result) {
oscData.setData('register', true);
oscData.setData('password', passwordSelector.val());
- } else if (!password) {
- $('#osc-password').focus();
- } else if (!confirm) {
- $('#osc-password-confirmation').focus();
}
return result;
diff --git a/view/frontend/web/js/view/payment.js b/view/frontend/web/js/view/payment.js
index b6c1705..a264862 100644
--- a/view/frontend/web/js/view/payment.js
+++ b/view/frontend/web/js/view/payment.js
@@ -21,7 +21,6 @@
define(
[
'ko',
- 'jquery',
'Magento_Checkout/js/view/payment',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/step-navigator',
@@ -31,7 +30,6 @@ define(
'mage/translate'
],
function (ko,
- $,
Component,
quote,
stepNavigator,
@@ -69,10 +67,6 @@ define(
if (!quote.paymentMethod()) {
this.errorValidationMessage($.mage.__('Please specify a payment method.'));
- $('html, body').scrollTop(
- $('#checkout-step-payment').offset().top - $(window).height()/2
- );
-
return false;
}
diff --git a/view/frontend/web/js/view/shipping.js b/view/frontend/web/js/view/shipping.js
index b085358..c9a5d25 100644
--- a/view/frontend/web/js/view/shipping.js
+++ b/view/frontend/web/js/view/shipping.js
@@ -161,32 +161,8 @@ define(
this.saveShippingAddress();
}
- var offsetHeight = $(window).height()/2;
if (!emailValidationResult) {
$(loginFormSelector + ' input[name=username]').focus();
- } else if (!shippingAddressValidationResult) {
- var errorMsgSelector = $('#co-shipping-form .mage-error:first').closest('.field');
- if (errorMsgSelector.length) {
- if (errorMsgSelector.find('select').length) {
- $('html, body').scrollTop(
- errorMsgSelector.find('select').offset().top - offsetHeight
- );
- errorMsgSelector.find('select').focus();
- } else if (errorMsgSelector.find('input').length) {
- $('html, body').scrollTop(
- errorMsgSelector.find('input').offset().top - offsetHeight
- );
- errorMsgSelector.find('input').focus();
- }
- }
- } else if (!shippingMethodValidationResult) {
- if ($('._warn[name="shippingAddress.postcode"]').length) {
- $('._warn[name="shippingAddress.postcode"]').find('input').focus();
- } else {
- $('html, body').scrollTop(
- $('#opc-shipping_method').offset().top - offsetHeight/3
- );
- }
}
return shippingMethodValidationResult && shippingAddressValidationResult && emailValidationResult;