-
Notifications
You must be signed in to change notification settings - Fork 4
/
m2-one-step-checkout-v2.4.4-v2.4.5-patch.sh
379 lines (361 loc) · 17 KB
/
m2-one-step-checkout-v2.4.4-v2.4.5-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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
diff --git a/Model/DefaultConfigProvider.php b/Model/DefaultConfigProvider.php
index b9345bd..1325e77 100644
--- a/Model/DefaultConfigProvider.php
+++ b/Model/DefaultConfigProvider.php
@@ -21,17 +21,15 @@
namespace Mageplaza\Osc\Model;
-use Magento\CatalogInventory\Api\StockRegistryInterface;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\AccountManagement;
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\GiftMessage\Model\CompositeConfigProvider;
-use Magento\Quote\Api\CartItemRepositoryInterface as QuoteItemRepository;
use Magento\Quote\Api\PaymentMethodManagementInterface;
use Magento\Quote\Api\ShippingMethodManagementInterface;
-use Magento\Quote\Model\Quote\Item;
use Mageplaza\Osc\Helper\Data as OscHelper;
+use Mageplaza\Osc\Model\Geoip\Database\Reader;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -70,23 +68,11 @@ class DefaultConfigProvider implements ConfigProviderInterface
protected $_oscHelper;
/**
- * @var QuoteItemRepository
- */
- protected $quoteItemRepository;
-
- /**
- * @var StockRegistryInterface
- */
- protected $stockRegistry;
-
- /**
* DefaultConfigProvider constructor.
* @param CheckoutSession $checkoutSession
* @param PaymentMethodManagementInterface $paymentMethodManagement
* @param ShippingMethodManagementInterface $shippingMethodManagement
* @param CompositeConfigProvider $configProvider
- * @param QuoteItemRepository $quoteItemRepository
- * @param StockRegistryInterface $stockRegistry
* @param ModuleManager $moduleManager
* @param OscHelper $oscHelper
*/
@@ -95,20 +81,16 @@ class DefaultConfigProvider implements ConfigProviderInterface
PaymentMethodManagementInterface $paymentMethodManagement,
ShippingMethodManagementInterface $shippingMethodManagement,
CompositeConfigProvider $configProvider,
- QuoteItemRepository $quoteItemRepository,
- StockRegistryInterface $stockRegistry,
ModuleManager $moduleManager,
OscHelper $oscHelper
)
{
- $this->checkoutSession = $checkoutSession;
- $this->paymentMethodManagement = $paymentMethodManagement;
- $this->shippingMethodManagement = $shippingMethodManagement;
+ $this->checkoutSession = $checkoutSession;
+ $this->paymentMethodManagement = $paymentMethodManagement;
+ $this->shippingMethodManagement = $shippingMethodManagement;
$this->giftMessageConfigProvider = $configProvider;
- $this->quoteItemRepository = $quoteItemRepository;
- $this->stockRegistry = $stockRegistry;
- $this->moduleManager = $moduleManager;
- $this->_oscHelper = $oscHelper;
+ $this->moduleManager = $moduleManager;
+ $this->_oscHelper = $oscHelper;
}
/**
@@ -121,12 +103,12 @@ class DefaultConfigProvider implements ConfigProviderInterface
}
$output = [
- 'shippingMethods' => $this->getShippingMethods(),
- 'selectedShippingRate' => !empty($existShippingMethod = $this->checkoutSession->getQuote()->getShippingAddress()->getShippingMethod())
+ 'shippingMethods' => $this->getShippingMethods(),
+ 'selectedShippingRate' => !empty($existShippingMethod = $this->checkoutSession->getQuote()->getShippingAddress()->getShippingMethod())
? $existShippingMethod : $this->_oscHelper->getDefaultShippingMethod(),
- 'paymentMethods' => $this->getPaymentMethods(),
+ 'paymentMethods' => $this->getPaymentMethods(),
'selectedPaymentMethod' => $this->_oscHelper->getDefaultPaymentMethod(),
- 'oscConfig' => $this->getOscConfig()
+ 'oscConfig' => $this->getOscConfig()
];
return $output;
@@ -138,39 +120,38 @@ class DefaultConfigProvider implements ConfigProviderInterface
private function getOscConfig()
{
return [
- 'addressFields' => $this->_oscHelper->getAddressHelper()->getAddressFields(),
- 'autocomplete' => [
- 'type' => $this->_oscHelper->getAutoDetectedAddress(),
+ 'addressFields' => $this->_oscHelper->getAddressHelper()->getAddressFields(),
+ 'autocomplete' => [
+ 'type' => $this->_oscHelper->getAutoDetectedAddress(),
'google_default_country' => $this->_oscHelper->getGoogleSpecificCountry(),
],
- 'register' => [
- 'dataPasswordMinLength' => $this->_oscHelper->getConfigValue(AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH),
+ 'register' => [
+ 'dataPasswordMinLength' => $this->_oscHelper->getConfigValue(AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH),
'dataPasswordMinCharacterSets' => $this->_oscHelper->getConfigValue(AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER)
],
- 'allowGuestCheckout' => $this->_oscHelper->getAllowGuestCheckout($this->checkoutSession->getQuote()),
- 'showBillingAddress' => $this->_oscHelper->getShowBillingAddress(),
- 'newsletterDefault' => $this->_oscHelper->isSubscribedByDefault(),
- 'isUsedGiftWrap' => (bool)$this->checkoutSession->getQuote()->getShippingAddress()->getUsedGiftWrap(),
- 'giftMessageOptions' => array_merge_recursive($this->giftMessageConfigProvider->getConfig(), [
+ 'allowGuestCheckout' => $this->_oscHelper->getAllowGuestCheckout($this->checkoutSession->getQuote()),
+ 'showBillingAddress' => $this->_oscHelper->getShowBillingAddress(),
+ 'newsletterDefault' => $this->_oscHelper->isSubscribedByDefault(),
+ 'isUsedGiftWrap' => (bool)$this->checkoutSession->getQuote()->getShippingAddress()->getUsedGiftWrap(),
+ 'giftMessageOptions' => array_merge_recursive($this->giftMessageConfigProvider->getConfig(), [
'isEnableOscGiftMessageItems' => $this->_oscHelper->isEnableGiftMessageItems()
]),
- 'isDisplaySocialLogin' => $this->isDisplaySocialLogin(),
- 'deliveryTimeOptions' => [
+ 'isDisplaySocialLogin' => $this->isDisplaySocialLogin(),
+ 'deliveryTimeOptions' => [
'deliveryTimeFormat' => $this->_oscHelper->getDeliveryTimeFormat(),
- 'deliveryTimeOff' => $this->_oscHelper->getDeliveryTimeOff(),
- 'houseSecurityCode' => $this->_oscHelper->isDisabledHouseSecurityCode()
+ 'deliveryTimeOff' => $this->_oscHelper->getDeliveryTimeOff(),
+ 'houseSecurityCode' => $this->_oscHelper->isDisabledHouseSecurityCode()
],
- 'isUsedMaterialDesign' => $this->_oscHelper->isUsedMaterialDesign(),
+ 'isUsedMaterialDesign' => $this->_oscHelper->isUsedMaterialDesign(),
'isAmazonAccountLoggedIn' => false,
- 'geoIpOptions' => [
+ 'geoIpOptions' => [
'isEnableGeoIp' => $this->_oscHelper->isEnableGeoIP(),
- 'geoIpData' => $this->_oscHelper->getAddressHelper()->getGeoIpData()
+ 'geoIpData' => $this->_oscHelper->getAddressHelper()->getGeoIpData()
],
- 'compatible' => [
+ 'compatible' => [
'isEnableModulePostNL' => $this->_oscHelper->isEnableModulePostNL(),
],
- 'show_toc' => $this->_oscHelper->getShowTOC(),
- 'qtyIncrements' => $this->getItemQtyIncrement()
+ 'show_toc' => $this->_oscHelper->getShowTOC()
];
}
@@ -183,11 +164,11 @@ class DefaultConfigProvider implements ConfigProviderInterface
private function getPaymentMethods()
{
$paymentMethods = [];
- $quote = $this->checkoutSession->getQuote();
+ $quote = $this->checkoutSession->getQuote();
if (!$quote->getIsVirtual()) {
foreach ($this->paymentMethodManagement->getList($quote->getId()) as $paymentMethod) {
$paymentMethods[] = [
- 'code' => $paymentMethod->getCode(),
+ 'code' => $paymentMethod->getCode(),
'title' => $paymentMethod->getTitle()
];
}
@@ -212,36 +193,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
}
/**
- * Retrieve quote item data
- *
- * @return array
- */
- private function getItemQtyIncrement()
- {
- $itemQty = [];
-
- try {
- $quoteId = $this->checkoutSession->getQuote()->getId();
- if ($quoteId) {
- /** @var array $quoteItems */
- $quoteItems = $this->quoteItemRepository->getList($quoteId);
-
- /** @var Item $item */
- foreach ($quoteItems as $item) {
- $stockItem = $this->stockRegistry->getStockItem($item->getProduct()->getId(), $item->getStore()->getWebsiteId());
- if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) {
- $itemQty[$item->getId()] = $stockItem->getQtyIncrements() ?: 1;
- }
- }
- }
- } catch (\Exception $e) {
- $itemQty = [];
- }
-
- return $itemQty;
- }
-
- /**
* @return bool
*/
private function isDisplaySocialLogin()
diff --git a/composer.json b/composer.json
index 9c516dc..963abf3 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"geoip2/geoip2": "~2.0"
},
"type": "magento2-module",
- "version": "2.4.5",
+ "version": "2.4.4",
"license": "proprietary",
"authors": [
{
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 72f727f..1fb6cb7 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -307,7 +307,7 @@
<validate>jscolor {hash:true,refine:false}</validate>
</field>
<field id="custom_css" sortOrder="100" type="textarea" showInDefault="1" showInWebsite="1" showInStore="1">
- <label>Custom CSS</label>
+ <label>Custom Css</label>
<comment><![CDATA[Example: .step-title{background-color: #1979c3;}]]></comment>
</field>
</group>
diff --git a/view/frontend/web/js/model/shipping-rates-validator.js b/view/frontend/web/js/model/shipping-rates-validator.js
index 5837c0c..4c24c30 100644
--- a/view/frontend/web/js/model/shipping-rates-validator.js
+++ b/view/frontend/web/js/model/shipping-rates-validator.js
@@ -46,8 +46,7 @@ define(
shippingService,
postcodeValidator,
$t,
- uiRegistry
- ) {
+ uiRegistry) {
'use strict';
var countryElement = null,
@@ -139,9 +138,7 @@ define(
if (element.component.indexOf('/group') !== -1) {
$.each(element.elems(), function (index, elem) {
- uiRegistry.async(elem.name)(function () {
- self.oscBindHandler(elem);
- });
+ self.oscBindHandler(elem);
});
} else if (element && element.hasOwnProperty('value')) {
element.on('value', function () {
diff --git a/view/frontend/web/js/view/billing-address.js b/view/frontend/web/js/view/billing-address.js
index ce1e334..b72c67f 100644
--- a/view/frontend/web/js/view/billing-address.js
+++ b/view/frontend/web/js/view/billing-address.js
@@ -194,9 +194,7 @@ define(
if (element.component.indexOf('/group') !== -1) {
$.each(element.elems(), function (index, elem) {
- registry.async(elem.name) (function () {
- self.bindHandler(elem);
- });
+ self.bindHandler(elem);
});
} else {
element.on('value', this.saveBillingAddress.bind(this, element.index));
@@ -273,7 +271,7 @@ define(
if (this.source.get('params.invalid')) {
var offsetHeight = $(window).height()/2,
errorMsgSelector = $('#billing-new-address-form .mage-error:first').closest('.field');
- errorMsgSelector = errorMsgSelector.length ? errorMsgSelector : $('#co-shipping-form .field-error:first').closest('.field');
+
if (errorMsgSelector.length) {
if (errorMsgSelector.find('select').length) {
$('html, body').scrollTop(
diff --git a/view/frontend/web/js/view/shipping.js b/view/frontend/web/js/view/shipping.js
index 60263ae..b085358 100644
--- a/view/frontend/web/js/view/shipping.js
+++ b/view/frontend/web/js/view/shipping.js
@@ -166,7 +166,6 @@ define(
$(loginFormSelector + ' input[name=username]').focus();
} else if (!shippingAddressValidationResult) {
var errorMsgSelector = $('#co-shipping-form .mage-error:first').closest('.field');
- errorMsgSelector = errorMsgSelector.length ? errorMsgSelector : $('#co-shipping-form .field-error:first').closest('.field');
if (errorMsgSelector.length) {
if (errorMsgSelector.find('select').length) {
$('html, body').scrollTop(
diff --git a/view/frontend/web/js/view/summary/item/details.js b/view/frontend/web/js/view/summary/item/details.js
index a77db93..d719bc1 100644
--- a/view/frontend/web/js/view/summary/item/details.js
+++ b/view/frontend/web/js/view/summary/item/details.js
@@ -30,12 +30,19 @@ define(
'mage/translate',
'Magento_Ui/js/modal/modal'
],
- function (_, $, Component, quote, updateItemAction, giftMessageItem, url, $t, modal) {
+ function (_,
+ $,
+ Component,
+ quote,
+ updateItemAction,
+ giftMessageItem,
+ url,
+ $t,
+ modal) {
"use strict";
var products = window.checkoutConfig.quoteItemData,
- giftMessageOptions = window.checkoutConfig.oscConfig.giftMessageOptions,
- qtyIncrements = window.checkoutConfig.oscConfig.qtyIncrements;
+ giftMessageOptions = window.checkoutConfig.oscConfig.giftMessageOptions;
return Component.extend({
@@ -183,18 +190,10 @@ define(
* @param event
*/
plusQty: function (id, event) {
- var target = $(event.target).prev().children(".item_qty"),
- itemId = parseInt(target.attr("id")),
- qty = parseInt(target.val());
-
- if (qtyIncrements.hasOwnProperty(itemId)) {
- var qtyDelta = qtyIncrements[itemId];
-
- qty = (Math.floor(qty / qtyDelta) + 1) * qtyDelta;
- } else {
- qty += 1;
- }
-
+ var target = $(event.target).prev().children(".item_qty");
+ var qty = parseInt(target.val()) + 1;
+ var itemId = parseInt(target.attr("id"));
+ //target.val(qty);
this.updateItem(itemId, qty);
},
@@ -205,18 +204,10 @@ define(
* @param event
*/
minusQty: function (item, event) {
- var target = $(event.target).next().children(".item_qty"),
- itemId = parseInt(target.attr("id")),
- qty = parseInt(target.val());
-
- if (qtyIncrements.hasOwnProperty(itemId)) {
- var qtyDelta = qtyIncrements[itemId];
-
- qty = (Math.ceil(qty / qtyDelta) -1) * qtyDelta;
- } else {
- qty -= 1;
- }
-
+ var target = $(event.target).next().children(".item_qty");
+ var qty = parseInt(target.val()) - 1;
+ var itemId = parseInt(target.attr("id"));
+ //target.val(qty);
this.updateItem(itemId, qty);
},
@@ -227,15 +218,9 @@ define(
* @param event
*/
changeQty: function (item, event) {
- var target = $(event.target),
- itemId = parseInt(target.attr("id")),
- qty = parseInt(target.val());
-
- if (qtyIncrements.hasOwnProperty(itemId) && (qty % qtyIncrements[itemId])) {
- var qtyDelta = qtyIncrements[itemId];
-
- qty = (Math.ceil(qty / qtyDelta) -1) * qtyDelta;
- }
+ var target = $(event.target);
+ var qty = parseInt(target.val());
+ var itemId = parseInt(target.attr("id"));
this.updateItem(itemId, qty);
},