-
Notifications
You must be signed in to change notification settings - Fork 4
/
m2-one-step-checkout-v2.3.6-v2.4.0-patch.sh
9451 lines (9319 loc) · 453 KB
/
m2-one-step-checkout-v2.3.6-v2.4.0-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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/Block/Adminhtml/System/Config/Geoip.php b/Block/Adminhtml/System/Config/Geoip.php
deleted file mode 100644
index a0f1b9a..0000000
--- a/Block/Adminhtml/System/Config/Geoip.php
+++ /dev/null
@@ -1,115 +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
- * @version 3.0.0
- * @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
- * @license https://www.mageplaza.com/LICENSE.txt
- */
-namespace Mageplaza\Osc\Block\Adminhtml\System\Config;
-
-use Magento\Backend\Block\Template\Context;
-use Magento\Config\Block\System\Config\Form\Field;
-use Magento\Framework\Data\Form\Element\AbstractElement;
-use Mageplaza\Osc\Helper\Data as HelperData;
-
-
-class Geoip extends Field
-{
- /**
- * @var string
- */
- protected $_template = 'Mageplaza_Osc::system/config/geoip.phtml';
-
- /**
- * @type \Mageplaza\Osc\Helper\Data
- */
- protected $_helperData;
-
- /**
- * @param Context $context
- * @param array $data
- */
- public function __construct(
- Context $context,
- HelperData $helperData,
- array $data = []
- ) {
- $this->_helperData = $helperData;
- parent::__construct($context, $data);
- }
-
- /**
- * Remove scope label
- *
- * @param AbstractElement $element
- * @return string
- */
- public function render(AbstractElement $element)
- {
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
- return parent::render($element);
- }
-
- /**
- * Return element html
- *
- * @param AbstractElement $element
- * @return string
- */
- protected function _getElementHtml(AbstractElement $element)
- {
- return $this->_toHtml();
- }
-
- /**
- * Return ajax url for collect button
- *
- * @return string
- */
- public function getAjaxUrl()
- {
- return $this->getUrl('onestepcheckout/system_config/geoip');
- }
-
- /**
- * Generate collect button html
- *
- * @return string
- */
- public function getButtonHtml()
- {
- $button = $this->getLayout()->createBlock(
- 'Magento\Backend\Block\Widget\Button'
- )->setData(
- [
- 'id' => 'geoip_button',
- 'label' => __('Download Library'),
- ]
- );
-
- return $button->toHtml();
- }
-
- /**
- * @return string
- */
- public function isDisplayIcon(){
- return $this->_helperData->checkHasLibrary() ? '' : 'hidden="hidden';
- }
-
-}
-?>
\ No newline at end of file
diff --git a/Block/Checkout/CompatibleConfig.php b/Block/Checkout/CompatibleConfig.php
deleted file mode 100644
index 38ff574..0000000
--- a/Block/Checkout/CompatibleConfig.php
+++ /dev/null
@@ -1,60 +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) 2016 Mageplaza (http://www.mageplaza.com/)
- * @license https://www.mageplaza.com/LICENSE.txt
- */
-
-namespace Mageplaza\Osc\Block\Checkout;
-
-use Magento\Framework\View\Element\Template;
-
-class CompatibleConfig extends Template
-{
- /**
- * @var string $_template
- */
- protected $_template = "onepage/compatible-config.phtml";
-
- /**
- * @var \Mageplaza\Osc\Helper\Config
- */
- protected $_oscConfig;
-
- /**
- * CompatibleConfig constructor.
- * @param Template\Context $context
- * @param array $data
- */
- public function __construct(
- Template\Context $context,
- \Mageplaza\Osc\Helper\Config $oscConfig,
- array $data = []
- )
- {
- parent::__construct($context, $data);
- $this->_oscConfig = $oscConfig;
- }
-
- /**
- * @return bool
- */
- public function isEnableModulePostNL()
- {
- return $this->_oscConfig->isEnableModulePostNL();
- }
-}
\ No newline at end of file
diff --git a/Block/Checkout/LayoutProcessor.php b/Block/Checkout/LayoutProcessor.php
index fb45521..8775312 100644
--- a/Block/Checkout/LayoutProcessor.php
+++ b/Block/Checkout/LayoutProcessor.php
@@ -116,11 +116,17 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso
}
/** Remove billing customer email if quote is not virtual */
- if (!$this->checkoutSession->getQuote()->isVirtual()) {
+ if (!$this->checkoutSession->getQuote()->isVirtual() && !$this->_oscHelper->isShowBillingAddressBeforeShippingAddress()) {
unset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billingAddress']
['children']['customer-email']);
}
+ /** Remove shipping customer email if show billing address before shipping address is enable */
+ if ($this->_oscHelper->isShowBillingAddressBeforeShippingAddress()) {
+ unset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']
+ ['children']['customer-email']);
+ }
+
/** Remove billing address in payment method content */
$fields = &$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'];
@@ -213,9 +219,6 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso
private function addAddressOption(&$fields)
{
$fieldPosition = $this->_oscHelper->getAddressFieldPosition();
-
- $this->rewriteFieldStreet($fields);
-
foreach ($fields as $code => &$field) {
$fieldConfig = isset($fieldPosition[$code]) ? $fieldPosition[$code] : [];
if (!sizeof($fieldConfig)) {
@@ -259,30 +262,6 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso
}
} elseif (isset($field['config']['elementTmpl']) && $field['config']['elementTmpl'] == "ui/form/element/input") {
$field['config']['elementTmpl'] = $template;
- if($this->_oscHelper->isUsedMaterialDesign()){
- $field['config']['template'] = 'Mageplaza_Osc/container/form/field';
- }
- }
-
- return $this;
- }
-
- /**
- * Change template street when enable material design
- * @param $fields
- * @return $this
- */
- public function rewriteFieldStreet(&$fields){
-
- if($this->_oscHelper->isUsedMaterialDesign()){
- $fields['country_id']['config']['template'] = 'Mageplaza_Osc/container/form/field';
- $fields['region_id']['config']['template'] = 'Mageplaza_Osc/container/form/field';
- foreach ($fields['street']['children'] as $key => $value){
- $fields['street']['children'][0]['label']= $fields['street']['label'];
- $fields['street']['children'][$key]['config']['template'] = 'Mageplaza_Osc/container/form/field';
- }
- $fields['street']['config']['fieldTemplate'] = 'Mageplaza_Osc/container/form/field';
- unset($fields['street']['label']);
}
return $this;
diff --git a/Block/Design.php b/Block/Design.php
index 5a55277..347b4fd 100644
--- a/Block/Design.php
+++ b/Block/Design.php
@@ -23,8 +23,6 @@ namespace Mageplaza\Osc\Block;
use Mageplaza\Osc\Helper\Config;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
-use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
-use Magento\Checkout\Model\Session as CheckoutSession;
/**
* Class Css
@@ -38,35 +36,19 @@ class Design extends Template
protected $_helperConfig;
/**
- * @var ThemeProviderInterface
- */
- protected $_themeProviderInterface;
-
- /**
- * @type \Magento\Checkout\Model\Session
- */
- private $checkoutSession;
-
- /**
- * @param Context $context
- * @param Config $helperConfig
- * @param ThemeProviderInterface $themeProviderInterface
- * @param CheckoutSession $checkoutSession
+ * @param \Magento\Framework\View\Element\Template\Context $context
+ * @param \Mageplaza\Osc\Helper\Config $helperConfig
* @param array $data
*/
public function __construct(
Context $context,
Config $helperConfig,
- ThemeProviderInterface $themeProviderInterface,
- CheckoutSession $checkoutSession,
array $data = []
) {
parent::__construct($context, $data);
- $this->_helperConfig = $helperConfig;
- $this->_themeProviderInterface = $themeProviderInterface;
- $this->checkoutSession = $checkoutSession;
+ $this->_helperConfig = $helperConfig;
}
/**
@@ -100,18 +82,4 @@ class Design extends Template
{
return $this->getHelperConfig()->getDesignConfig();
}
-
- /**
- * @return string
- */
- public function getCurrentTheme(){
- return $this->_themeProviderInterface->getThemeById($this->getHelperConfig()->getCurrentThemeId())->getCode();
- }
-
- /**
- * @return bool
- */
- public function isVirtual(){
- return $this->checkoutSession->getQuote()->isVirtual();
- }
}
diff --git a/Block/Order/View/DeliveryTime.php b/Block/Order/View/DeliveryTime.php
index 3264fba..7120dc7 100644
--- a/Block/Order/View/DeliveryTime.php
+++ b/Block/Order/View/DeliveryTime.php
@@ -62,19 +62,6 @@ class DeliveryTime extends \Magento\Framework\View\Element\Template
return '';
}
- /**
- * Get osc house security code
- *
- * @return string
- */
- public function getHouseSecurityCode()
- {
- if ($order = $this->getOrder()) {
- return $order->getOscOrderHouseSecurityCode();
- }
- return '';
- }
-
/**
* Get current order
*
diff --git a/Block/Survey.php b/Block/Survey.php
index d68cc3b..67020e9 100644
--- a/Block/Survey.php
+++ b/Block/Survey.php
@@ -70,7 +70,7 @@ class Survey extends Template
*/
public function isEnableSurvey()
{
- return $this->_helperData->getConfig()->isEnabled() && !$this->_helperData->getConfig()->isDisableSurvey();
+ return $this->_helperData->getConfig()->isDisableSurvey();
}
public function getLastOrderId(){
diff --git a/CHANGELOG b/CHANGELOG
deleted file mode 100644
index f901905..0000000
--- a/CHANGELOG
+++ /dev/null
@@ -1 +0,0 @@
-CHANGELOG: https://www.mageplaza.com/changelog/m2-one-step-checkout.txt
\ No newline at end of file
diff --git a/Controller/Add/Index.php b/Controller/Add/Index.php
index 46f63ce..f3ede5e 100644
--- a/Controller/Add/Index.php
+++ b/Controller/Add/Index.php
@@ -31,13 +31,13 @@ class Index extends \Magento\Checkout\Controller\Cart\Add
*/
public function execute()
{
- $productId = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : 11;
+ $productId = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : 11;
$storeId = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId();
$product = $this->productRepository->getById($productId, false, $storeId);
$this->cart->addProduct($product, []);
$this->cart->save();
- return $this->goBack($this->_url->getUrl('onestepcheckout'));
+ return $this->goBack($this->_url->getUrl('onestepcheckout'));
}
}
diff --git a/Controller/Adminhtml/System/Config/Geoip.php b/Controller/Adminhtml/System/Config/Geoip.php
deleted file mode 100644
index b2ff11c..0000000
--- a/Controller/Adminhtml/System/Config/Geoip.php
+++ /dev/null
@@ -1,107 +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
- * @version 3.0.0
- * @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
- * @license https://www.mageplaza.com/LICENSE.txt
- */
-
-namespace Mageplaza\Osc\Controller\Adminhtml\System\Config;
-
-use Magento\Backend\App\Action;
-use Magento\Backend\App\Action\Context;
-use Magento\Framework\Controller\Result\JsonFactory;
-use Magento\Framework\App\Filesystem\DirectoryList;
-use \Mageplaza\Osc\Helper\Config as OscConfig;
-
-class Geoip extends Action
-{
-
- /**
- * @type \Magento\Framework\Controller\Result\JsonFactory
- */
- protected $resultJsonFactory;
-
- /**
- * @type \Magento\Framework\App\Filesystem\DirectoryList
- */
- protected $_directoryList;
-
- /**
- * @var OscConfig
- */
- protected $_oscConfig;
-
-
- /**
- * @param Context $context
- * @param JsonFactory $resultJsonFactory
- * @param DirectoryList $directoryList
- * @param OscConfig $config
- */
- public function __construct(
- Context $context,
- JsonFactory $resultJsonFactory,
- DirectoryList $directoryList,
- OscConfig $config
- )
- {
- $this->resultJsonFactory = $resultJsonFactory;
- $this->_directoryList = $directoryList;
- $this->_oscConfig = $config;
- parent::__construct($context);
- }
-
-
- public function execute()
- {
- $status=false;
- try {
- $path = $this->_directoryList->getPath('var').'/Mageplaza/Osc/GeoIp';
- if (!file_exists($path)) {
- mkdir($path, 0777, true);
- }
- $folder=scandir($path,true);
- $pathFile= $path.'/'.$folder[0].'/GeoLite2-City.mmdb';
-
- if(file_exists($pathFile)){
- foreach(scandir($path.'/'.$folder[0],true) as $filename){
- if($filename== '..'|| $filename== '.' ){
- continue;
- }
- @unlink($path.'/'.$folder[0].'/'. $filename);
- }
- @rmdir($path.'/'.$folder[0]);
- }
-
- file_put_contents($path.'/GeoLite2-City.tar.gz', fopen($this->_oscConfig->getDownloadPath(), 'r'));
- $phar = new \PharData($path.'/GeoLite2-City.tar.gz');
- $phar->extractTo($path);
- $status = true;
- $message = __("Download library success!");
- } catch (\Exception $e) {
- echo $e->getMessage();
- $message = __("Can't download file. Please try again!");
- }
-
- /** @var \Magento\Framework\Controller\Result\Json $result */
- $result = $this->resultJsonFactory->create();
- return $result->setData(['success' => $status, 'message' => $message]);
- }
-}
-
-?>
\ No newline at end of file
diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php
index 6a5d52b..56de2d9 100644
--- a/Controller/Index/Index.php
+++ b/Controller/Index/Index.php
@@ -72,25 +72,8 @@ class Index extends \Magento\Checkout\Controller\Onepage
{
$shippingAddress = $quote->getShippingAddress();
if (!$shippingAddress->getCountryId()) {
- if(!empty($this->_checkoutHelper->getConfig()->getDefaultCountryId())){
- $defaultCountryId = $this->_checkoutHelper->getConfig()->getDefaultCountryId();
- }else{
- /**
- * Get default country id from Geo Ip or Locale
- */
- if($this->_checkoutHelper->checkHasLibrary()){
- try {
- $ip = $_SERVER['REMOTE_ADDR']!= '127.0.0.1' ? $_SERVER['REMOTE_ADDR'] : '123.16.189.71';
- $data = $this->_checkoutHelper->getGeoIpData($this->_objectManager->get('Mageplaza\Osc\Model\Geoip\Database\Reader')->city($ip));
- $defaultCountryId = $data['country_id'];
- } catch (\Exception $e) {
- $defaultCountryId = $this->getDefaultCountryFromLocale();
- }
- }else{
- $defaultCountryId = $this->getDefaultCountryFromLocale();
- }
- }
- $shippingAddress->setCountryId($defaultCountryId)->setCollectShippingRates(true);
+ $shippingAddress->setCountryId($this->_checkoutHelper->getConfig()->getDefaultCountryId())
+ ->setCollectShippingRates(true);
}
$method = null;
@@ -134,13 +117,4 @@ class Index extends \Magento\Checkout\Controller\Onepage
return false;
}
-
- /**
- * Get default country id from locale
- * @return string
- */
- public function getDefaultCountryFromLocale(){
- $locale = $this->_objectManager->get('Magento\Framework\Locale\Resolver')->getLocale();
- return substr($locale, strrpos($locale, "_") + 1);
- }
}
diff --git a/Helper/Config.php b/Helper/Config.php
index 0f85d2f..f21c4c8 100644
--- a/Helper/Config.php
+++ b/Helper/Config.php
@@ -30,6 +30,7 @@ use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\Core\Helper\AbstractData;
use Mageplaza\Osc\Model\System\Config\Source\ComponentPosition;
+use Magento\Framework\Module\Manager as ModuleManager;
/**
* Class Config
@@ -52,12 +53,6 @@ class Config extends AbstractData
/** Design configuration path */
const DESIGN_CONFIGUARATION = 'osc/design_configuration';
- /** Geo configuration path */
- const GEO_IP_CONFIGUARATION = 'osc/geoip_configuration';
-
- /** Is enable Geo Ip path */
- const GEO_IP_IS_ENABLED = 'osc/geoip_configuration/is_enable_geoip';
-
/** @var \Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory */
protected $_addressesFactory;
@@ -71,6 +66,11 @@ class Config extends AbstractData
private $attributeMetadataDataProvider;
/**
+ * @type \Magento\Framework\Module\Manager
+ */
+ protected $_moduleManager;
+
+ /**
* Config constructor.
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\ObjectManagerInterface $objectManager
@@ -79,6 +79,7 @@ class Config extends AbstractData
* @param \Magento\Customer\Model\ResourceModel\Address\Attribute\CollectionFactory $addressesFactory
* @param \Magento\Customer\Model\ResourceModel\Attribute\CollectionFactory $customerFactory
* @param \Magento\Customer\Model\AttributeMetadataDataProvider $attributeMetadataDataProvider
+ * @param \Magento\Framework\Module\Manager $moduleManager
*/
public function __construct(
Context $context,
@@ -87,7 +88,8 @@ class Config extends AbstractData
Address $addressHelper,
AddressFactory $addressesFactory,
CustomerFactory $customerFactory,
- AttributeMetadataDataProvider $attributeMetadataDataProvider
+ AttributeMetadataDataProvider $attributeMetadataDataProvider,
+ ModuleManager $moduleManager
)
{
parent::__construct($context, $objectManager, $storeManager);
@@ -96,6 +98,7 @@ class Config extends AbstractData
$this->_addressesFactory = $addressesFactory;
$this->_customerFactory = $customerFactory;
$this->attributeMetadataDataProvider = $attributeMetadataDataProvider;
+ $this->_moduleManager = $moduleManager;
}
/**
@@ -392,6 +395,17 @@ class Config extends AbstractData
}
/**
+ * Show billing address before shipping address
+ *
+ * @param null $store
+ * @return bool
+ */
+ public function isShowBillingAddressBeforeShippingAddress($store = null)
+ {
+ return $this->getGeneralConfig('show_billing_before_shipping', $store) && $this->getShowBillingAddress();
+ }
+
+ /**
* Google api key
*
* @param null $store
@@ -548,17 +562,6 @@ class Config extends AbstractData
}
/**
- * Gift message items
- * @param null $store
- * @return bool
- */
- public function isEnableGiftMessageItems($store = null)
- {
- return (bool)$this->getDisplayConfig('is_enabled_gift_message_items', $store);
- }
-
-
- /**
* Gift wrap block will be hided if this function return 'true'
*
* @param null $store
@@ -659,16 +662,6 @@ class Config extends AbstractData
}
/**
- * House Security Code
- * @param null $store
- * @return bool
- */
- public function isDisabledHouseSecurityCode($store = null)
- {
- return !$this->getDisplayConfig('is_enabled_house_security_code', $store);
- }
-
- /**
* Delivery Time Format
*
* @param null $store
@@ -697,7 +690,8 @@ class Config extends AbstractData
* @param null $store
* @return bool
*/
- public function isDisableSurvey($store = null){
+ public function isDisableSurvey($store = null)
+ {
return !$this->getDisplayConfig('is_enabled_survey', $store);
}
@@ -706,7 +700,8 @@ class Config extends AbstractData
* @param null $store
* @return mixed
*/
- public function getSurveyQuestion($store = null){
+ public function getSurveyQuestion($store = null)
+ {
return $this->getDisplayConfig('survey_question', $store);
}
@@ -715,8 +710,9 @@ class Config extends AbstractData
* @param null $stores
* @return mixed
*/
- public function getSurveyAnswers($stores = null){
- return unserialize($this->getDisplayConfig('survey_answers',$stores));
+ public function getSurveyAnswers($stores = null)
+ {
+ return unserialize($this->getDisplayConfig('survey_answers', $stores));
}
/**
@@ -724,8 +720,9 @@ class Config extends AbstractData
* @param null $stores
* @return mixed
*/
- public function isAllowCustomerAddOtherOption($stores = null){
- return $this->getDisplayConfig('allow_customer_add_other_option',$stores);
+ public function isAllowCustomerAddOtherOption($stores = null)
+ {
+ return $this->getDisplayConfig('allow_customer_add_other_option', $stores);
}
/**
@@ -751,30 +748,7 @@ class Config extends AbstractData
return $this->getConfigValue($code, $store);
}
- /**
- * @return bool
- */
- public function isUsedMaterialDesign(){
- return $this->getDesignConfig('page_design') == 'material' ? true : false;
- }
- /***************************** GeoIP Configuration *****************************
- *
- * @param null $store
- * @return mixed
- */
- public function isEnableGeoIP($store = null)
- {
- return boolval($this->getConfigValue(self::GEO_IP_CONFIGUARATION.'/is_enable_geoip', $store));
- }
-
- /**
- * @param null $store
- * @return mixed
- */
- public function getDownloadPath($store = null){
- return $this->getConfigValue(self::GEO_IP_CONFIGUARATION.'/download_path',$store);
- }
/***************************** Compatible Modules *****************************
*
* @return bool
@@ -783,20 +757,4 @@ class Config extends AbstractData
{
return $this->_moduleManager->isOutputEnabled('MultiSafepay_Connect');
}
-
- /**
- * @return bool
- */
- public function isEnableModulePostNL()
- {
- return $this->isModuleOutputEnabled('TIG_PostNL');
- }
-
- /**
- * Get current theme id
- * @return mixed
- */
- public function getCurrentThemeId(){
- return $this->getConfigValue(\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID);
- }
}
diff --git a/Helper/Data.php b/Helper/Data.php
index e12ec9f..e32ba78 100644
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -27,9 +27,6 @@ use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\Core\Helper\AbstractData as AbstractHelper;
-use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\Locale\Resolver;
-use Magento\Directory\Model\Region;
/**
* Class Data
@@ -53,30 +50,12 @@ class Data extends AbstractHelper
protected $_priceCurrency;
/**
- * @type \Magento\Framework\App\Filesystem\DirectoryList
- */
- protected $_directoryList;
-
- /**
- * @type \Magento\Framework\Locale\Resolver
- */
- protected $_resolver;
-
- /**
- * @type \Magento\Directory\Model\Region
- */
- protected $_region;
-
- /**
- * @param Context $context
- * @param HelperData $helperData
- * @param StoreManagerInterface $storeManager
- * @param Config $helperConfig
- * @param ObjectManagerInterface $objectManager
- * @param PriceCurrencyInterface $priceCurrency
- * @param DirectoryList $directoryList
- * @param Resolver $resolver
- * @param Region $region
+ * @param \Magento\Framework\App\Helper\Context $context
+ * @param \Magento\Checkout\Helper\Data $helperData
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @param \Mageplaza\Osc\Helper\Config $helperConfig
+ * @param \Magento\Framework\ObjectManagerInterface $objectManager
+ * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
*/
public function __construct(
Context $context,
@@ -84,19 +63,12 @@ class Data extends AbstractHelper
StoreManagerInterface $storeManager,
Config $helperConfig,
ObjectManagerInterface $objectManager,
- PriceCurrencyInterface $priceCurrency,
- DirectoryList $directoryList,
- Resolver $resolver,
- Region $region
+ PriceCurrencyInterface $priceCurrency
)
{
$this->_helperData = $helperData;
$this->_helperConfig = $helperConfig;
$this->_priceCurrency = $priceCurrency;
- $this->_directoryList = $directoryList;
- $this->_resolver = $resolver;
- $this->_region = $region;
-
parent::__construct($context, $objectManager, $storeManager);
}
@@ -153,85 +125,4 @@ class Data extends AbstractHelper
return $this->convertPrice($baseOscGiftWrapAmount, $quote->getStore());
}
-
- /**
- * Check has library at path var/Mageplaza/Osc/GeoIp/
- * @return bool|string
- */
- public function checkHasLibrary()
- {
- $path = $this->_directoryList->getPath('var') . '/Mageplaza/Osc/GeoIp';
- if (!file_exists($path)) return false;
- $folder = scandir($path, true);
- $pathFile = $path . '/' . $folder[0] . '/GeoLite2-City.mmdb';
- if (!file_exists($pathFile)) return false;
-
- return $pathFile;
- }
-
- /**
- * @param $data
- * @return mixed
- */
- public function getGeoIpData($data)
- {
- $geoIpData['city'] = $this->filterData($data, 'city', 'names');
- $geoIpData['country_id'] = $this->filterData($data, 'country', 'iso_code', false);
- if (!empty($this->getRegionId($data, $geoIpData['country_id']))) {
- $geoIpData['region_id'] = $this->getRegionId($data, $geoIpData['country_id']);
- } else {
- $geoIpData['region'] = $this->filterData($data, 'subdivisions', 'names');
- }
- if (isset($data['postal'])) {
- $geoIpData['postcode'] = $this->filterData($data, 'postal', 'code', false);
- }
-
- return $geoIpData;
- }
-
- /**
- * Filter GeoIP data
- * @param $data
- * @param $field
- * @param $child
- * @param bool|true $convert
- * @return string
- */
- public function filterData($data, $field, $child, $convert = true)
- {
- $output = '';
- if (isset($data[$field]) && is_array($data[$field])) {
- if ($field == 'subdivisions') {
- foreach ($data[$field][0] as $key => $value) {
- $data[$field][$key] = $value;
- }
- }
- if (isset($data[$field][$child])) {
- if ($convert) {
- if (is_array($data[$field][$child])) {
- $locale = $this->_resolver->getLocale();
- $language = substr($locale, 0, 2) ? substr($locale, 0, 2) : 'en';
- $output = isset($data[$field][$child][$language]) ? $data[$field][$child][$language] : '';
- }
- } else {
- $output = $data[$field][$child];
- }
- }
- }
-
- return $output;
- }
-
- /**
- * Find region id by Country
- * @param $data
- * @param $country
- * @return mixed
- */
- public function getRegionId($data, $country)
- {
- $regionId = $this->_region->loadByCode($this->filterData($data, 'subdivisions', 'iso_code', false), $country)->getId();
-
- return $regionId;
- }
}
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index f9c459c..0000000
--- a/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-LICENSE: https://www.mageplaza.com/LICENSE.txt
\ No newline at end of file
diff --git a/Model/DefaultConfigProvider.php b/Model/DefaultConfigProvider.php
index c054f2c..333ac80 100644
--- a/Model/DefaultConfigProvider.php
+++ b/Model/DefaultConfigProvider.php
@@ -18,7 +18,6 @@
* @copyright Copyright (c) 2016 Mageplaza (http://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-
namespace Mageplaza\Osc\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
@@ -29,8 +28,6 @@ use Magento\Quote\Api\PaymentMethodManagementInterface;
use Magento\Quote\Api\ShippingMethodManagementInterface;
use Mageplaza\Osc\Helper\Config as OscConfig;
use Magento\Framework\Module\Manager as ModuleManager;
-use Mageplaza\Osc\Helper\Data as HelperData;
-use Mageplaza\Osc\Model\Geoip\Database\Reader;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -70,16 +67,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
protected $moduleManager;
/**
- * @type \Mageplaza\Osc\Helper\Data
- */
- protected $_helperData;
-
- /**
- * @type \Mageplaza\Osc\Model\Geoip\Database\Reader
- */
- protected $_geoIpData;
-
- /**
* DefaultConfigProvider constructor.
* @param CheckoutSession $checkoutSession
* @param PaymentMethodManagementInterface $paymentMethodManagement
@@ -87,8 +74,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
* @param OscConfig $oscConfig
* @param CompositeConfigProvider $configProvider
* @param ModuleManager $moduleManager
- * @param HelperData $helperData
- * @param Reader $geoIpData
*/
public function __construct(
CheckoutSession $checkoutSession,
@@ -96,9 +81,7 @@ class DefaultConfigProvider implements ConfigProviderInterface
ShippingMethodManagementInterface $shippingMethodManagement,
OscConfig $oscConfig,
CompositeConfigProvider $configProvider,
- ModuleManager $moduleManager,
- HelperData $helperData,
- Reader $geoIpData
+ ModuleManager $moduleManager
)
{
$this->checkoutSession = $checkoutSession;
@@ -107,8 +90,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
$this->oscConfig = $oscConfig;
$this->giftMessageConfigProvider = $configProvider;
$this->moduleManager = $moduleManager;
- $this->_helperData = $helperData;
- $this->_geoIpData = $geoIpData;
}
/**
@@ -122,7 +103,7 @@ class DefaultConfigProvider implements ConfigProviderInterface
$output = [
'shippingMethods' => $this->getShippingMethods(),
- 'selectedShippingRate' => !empty($existShippingMethod = $this->checkoutSession->getQuote()->getShippingAddress()->getShippingMethod()) ? $existShippingMethod : $this->oscConfig->getDefaultShippingMethod(),
+ 'selectedShippingRate' => $this->oscConfig->getDefaultShippingMethod(),