forked from mageplaza/m2-one-step-checkout-releases
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2-one-step-checkout-v2.2.0-v2.3.0-patch.sh
1836 lines (1796 loc) · 80.9 KB
/
m2-one-step-checkout-v2.2.0-v2.3.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/Order/View/DeliveryTime.php b/Block/Order/View/DeliveryTime.php
deleted file mode 100644
index 7120dc7..0000000
--- a/Block/Order/View/DeliveryTime.php
+++ /dev/null
@@ -1,74 +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://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
- * @copyright Copyright (c) 2016 Mageplaza (https://www.mageplaza.com/)
- * @license http://mageplaza.com/LICENSE.txt
- */
-namespace Mageplaza\Osc\Block\Order\View;
-
-/**
- * Class DeliveryTime
- * @package Mageplaza\Osc\Block\Order\View
- */
-class DeliveryTime extends \Magento\Framework\View\Element\Template
-{
- /**
- * @type \Magento\Framework\Registry|null
- */
- protected $_coreRegistry = null;
-
- /**
- * @param \Magento\Framework\View\Element\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param array $data
- */
- public function __construct(
- \Magento\Framework\View\Element\Template\Context $context,
- \Magento\Framework\Registry $registry,
- array $data = []
- )
- {
-
- $this->_coreRegistry = $registry;
-
- parent::__construct($context, $data);
- }
-
- /**
- * Get osc delivery time
- *
- * @return string
- */
- public function getDeliveryTime()
- {
- if ($order = $this->getOrder()) {
- return $order->getOscDeliveryTime();
- }
-
- return '';
- }
-
- /**
- * Get current order
- *
- * @return mixed
- */
- public function getOrder()
- {
- return $this->_coreRegistry->registry('current_order');
- }
-}
diff --git a/Controller/Add/Index.php b/Controller/Add/Index.php
index d49c4bc..20643b4 100644
--- a/Controller/Add/Index.php
+++ b/Controller/Add/Index.php
@@ -32,7 +32,7 @@ class Index extends \Magento\Checkout\Controller\Cart\Add
public function execute()
{
// $this->_objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
- $productId = 8;
+ $productId = 36;
$storeId = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId();
$product = $this->productRepository->getById($productId, false, $storeId);
diff --git a/Helper/Config.php b/Helper/Config.php
index d7017c7..4e62529 100644
--- a/Helper/Config.php
+++ b/Helper/Config.php
@@ -506,9 +506,9 @@ class Config extends AbstractData
* @param null $store
* @return mixed
*/
- public function isDisabledGiftMessage($store = null)
+ public function isEnabledGiftMessage($store = null)
{
- return !$this->getDisplayConfig('is_enabled_gift_message', $store);
+ return !$this->getDisplayConfig('is_enabled_giftmessage', $store);
}
/**
@@ -591,52 +591,6 @@ class Config extends AbstractData
return $this->getDisplayConfig('is_checked_newsletter', $store);
}
- /**
- * Social Login On Checkout Page
- * @param null $store
- * @return bool
- */
- public function isDisabledSocialLoginOnCheckout($store = null)
- {
- return !$this->getDisplayConfig('is_enabled_social_login', $store);
- }
-
- /**
- * Delivery Time
- * @param null $store
- * @return bool
- */
- public function isDisabledDeliveryTime($store = null)
- {
- return !$this->getDisplayConfig('is_enabled_delivery_time', $store);
- }
-
- /**
- * Delivery Time Format
- *
- * @param null $store
- *
- * @return string 'dd/mm/yy'|'mm/dd/yy'|'yy/mm/dd'
- */
- public function getDeliveryTimeFormat($store = null)
- {
- $deliveryTimeFormat = $this->getDisplayConfig('delivery_time_format', $store);
-
- return !empty($deliveryTimeFormat) ? $deliveryTimeFormat : 'dd/mm/yy';
- }
-
- /**
- * Delivery Time Off
- * @param null $store
- * @return bool|mixed
- */
- public function getDeliveryTimeOff($store = null)
- {
- $deliveryTimeOff = $this->getDisplayConfig('delivery_time_off', $store);
-
- return !empty($deliveryTimeOff) ? $deliveryTimeOff : false;
- }
-
/***************************** Design Configuration *****************************
*
* @param null $store
diff --git a/Model/CheckoutManagement.php b/Model/CheckoutManagement.php
index 24fdc8e..a48dcc3 100644
--- a/Model/CheckoutManagement.php
+++ b/Model/CheckoutManagement.php
@@ -24,14 +24,11 @@ use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\UrlInterface;
-use Magento\GiftMessage\Model\GiftMessageManager;
-use Magento\GiftMessage\Model\Message;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\CartTotalRepositoryInterface;
use Magento\Quote\Api\PaymentMethodManagementInterface;
use Magento\Quote\Api\ShippingMethodManagementInterface;
use Mageplaza\Osc\Api\CheckoutManagementInterface;
-use Mageplaza\Osc\Helper\Config as OscConfig;
use Mageplaza\Osc\Model\OscDetailsFactory;
/**
@@ -85,34 +82,14 @@ class CheckoutManagement implements CheckoutManagementInterface
protected $shippingInformationManagement;
/**
- * @type \Mageplaza\Osc\Helper\Config
- */
- protected $oscConfig;
-
- /**
- * @var Message
- */
- protected $giftMessage;
-
- /**
- * @var GiftMessageManager
- */
- protected $giftMessageManagement;
-
-
- /**
- * CheckoutManagement constructor.
- * @param CartRepositoryInterface $cartRepository
+ * @param \Magento\Quote\Api\CartRepositoryInterface $cartRepository
* @param \Mageplaza\Osc\Model\OscDetailsFactory $oscDetailsFactory
- * @param ShippingMethodManagementInterface $shippingMethodManagement
- * @param PaymentMethodManagementInterface $paymentMethodManagement
- * @param CartTotalRepositoryInterface $cartTotalsRepository
- * @param UrlInterface $urlBuilder
+ * @param \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagement
+ * @param \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement
+ * @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
+ * @param \Magento\Framework\UrlInterface $urlBuilder
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement
- * @param OscConfig $oscConfig
- * @param Message $giftMessage
- * @param GiftMessageManager $giftMessageManager
*/
public function __construct(
CartRepositoryInterface $cartRepository,
@@ -122,10 +99,7 @@ class CheckoutManagement implements CheckoutManagementInterface
CartTotalRepositoryInterface $cartTotalsRepository,
UrlInterface $urlBuilder,
\Magento\Checkout\Model\Session $checkoutSession,
- \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement,
- OscConfig $oscConfig,
- Message $giftMessage,
- GiftMessageManager $giftMessageManager
+ \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement
)
{
$this->cartRepository = $cartRepository;
@@ -136,9 +110,6 @@ class CheckoutManagement implements CheckoutManagementInterface
$this->_urlBuilder = $urlBuilder;
$this->checkoutSession = $checkoutSession;
$this->shippingInformationManagement = $shippingInformationManagement;
- $this->oscConfig = $oscConfig;
- $this->giftMessage = $giftMessage;
- $this->giftMessageManagement = $giftMessageManager;
}
/**
@@ -254,7 +225,6 @@ class CheckoutManagement implements CheckoutManagementInterface
try {
$additionInformation['customerAttributes'] = $customerAttributes;
$this->checkoutSession->setOscData($additionInformation);
- $this->addGiftMessage($cartId, $additionInformation);
if ($addressInformation->getShippingAddress()) {
$this->shippingInformationManagement->saveAddressInformation($cartId, $addressInformation);
@@ -265,23 +235,4 @@ class CheckoutManagement implements CheckoutManagementInterface
return true;
}
-
- /**
- * @param $cartId
- * @param $additionInformation
- * @throws \Magento\Framework\Exception\CouldNotSaveException
- */
- public function addGiftMessage($cartId, $additionInformation)
- {
- /** @var \Magento\Quote\Model\Quote $quote */
- $quote = $this->cartRepository->getActive($cartId);
-
- if (!$this->oscConfig->isDisabledGiftMessage()) {
- $giftMessage = json_decode($additionInformation['giftMessage'], true);
- $this->giftMessage->setSender($giftMessage['sender']);
- $this->giftMessage->setRecipient($giftMessage['recipient']);
- $this->giftMessage->setMessage($giftMessage['message']);
- $this->giftMessageManagement->setMessage($quote, 'quote', $this->giftMessage);
- }
- }
}
diff --git a/Model/DefaultConfigProvider.php b/Model/DefaultConfigProvider.php
index d95d406..26fd722 100644
--- a/Model/DefaultConfigProvider.php
+++ b/Model/DefaultConfigProvider.php
@@ -23,11 +23,9 @@ namespace Mageplaza\Osc\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\AccountManagement;
-use Magento\GiftMessage\Model\CompositeConfigProvider;
use Magento\Quote\Api\PaymentMethodManagementInterface;
use Magento\Quote\Api\ShippingMethodManagementInterface;
use Mageplaza\Osc\Helper\Config as OscConfig;
-use Magento\Framework\Module\Manager as ModuleManager;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -57,39 +55,22 @@ class DefaultConfigProvider implements ConfigProviderInterface
protected $oscConfig;
/**
- * @var \Magento\Checkout\Model\CompositeConfigProvider
- */
- protected $giftMessageConfigProvider;
-
- /**
- * @var ModuleManager
- */
- protected $moduleManager;
-
- /**
- * DefaultConfigProvider constructor.
- * @param CheckoutSession $checkoutSession
- * @param PaymentMethodManagementInterface $paymentMethodManagement
- * @param ShippingMethodManagementInterface $shippingMethodManagement
- * @param OscConfig $oscConfig
- * @param CompositeConfigProvider $configProvider
- * @param ModuleManager $moduleManager
+ * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @param \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement
+ * @param \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagement
+ * @param \Mageplaza\Osc\Helper\Config $oscConfig
*/
public function __construct(
CheckoutSession $checkoutSession,
PaymentMethodManagementInterface $paymentMethodManagement,
ShippingMethodManagementInterface $shippingMethodManagement,
- OscConfig $oscConfig,
- CompositeConfigProvider $configProvider,
- ModuleManager $moduleManager
+ OscConfig $oscConfig
)
{
- $this->checkoutSession = $checkoutSession;
- $this->paymentMethodManagement = $paymentMethodManagement;
- $this->shippingMethodManagement = $shippingMethodManagement;
- $this->oscConfig = $oscConfig;
- $this->giftMessageConfigProvider = $configProvider;
- $this->moduleManager = $moduleManager;
+ $this->checkoutSession = $checkoutSession;
+ $this->paymentMethodManagement = $paymentMethodManagement;
+ $this->shippingMethodManagement = $shippingMethodManagement;
+ $this->oscConfig = $oscConfig;
}
/**
@@ -118,25 +99,19 @@ class DefaultConfigProvider implements ConfigProviderInterface
private function getOscConfig()
{
return [
- 'addressFields' => $this->getAddressFields(),
- 'autocomplete' => [
+ 'addressFields' => $this->getAddressFields(),
+ 'autocomplete' => [
'type' => $this->oscConfig->getAutoDetectedAddress(),
'google_default_country' => $this->oscConfig->getGoogleSpecificCountry(),
],
- 'register' => [
+ 'register' => [
'dataPasswordMinLength' => $this->oscConfig->getConfigValue(AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH),
'dataPasswordMinCharacterSets' => $this->oscConfig->getConfigValue(AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER)
],
- 'allowGuestCheckout' => $this->oscConfig->getAllowGuestCheckout(),
- 'showBillingAddress' => $this->oscConfig->getShowBillingAddress(),
- 'newsletterDefault' => $this->oscConfig->isSubscribedByDefault(),
- 'isUsedGiftWrap' => (bool)$this->checkoutSession->getQuote()->getShippingAddress()->getUsedGiftWrap(),
- 'giftMessageOptions' => $this->giftMessageConfigProvider->getConfig(),
- 'isDisplaySocialLogin' => $this->isDisplaySocialLogin(),
- 'deliveryTimeOptions' => [
- 'deliveryTimeFormat' => $this->oscConfig->getDeliveryTimeFormat(),
- 'deliveryTimeOff' => $this->oscConfig->getDeliveryTimeOff()
- ]
+ 'allowGuestCheckout' => $this->oscConfig->getAllowGuestCheckout(),
+ 'showBillingAddress' => $this->oscConfig->getShowBillingAddress(),
+ 'newsletterDefault' => $this->oscConfig->isSubscribedByDefault(),
+ 'isUsedGiftWrap' => (bool)$this->checkoutSession->getQuote()->getShippingAddress()->getUsedGiftWrap()
];
}
@@ -183,12 +158,4 @@ class DefaultConfigProvider implements ConfigProviderInterface
return $methodLists;
}
-
- /**
- * @return bool
- */
- private function isDisplaySocialLogin(){
-
- return $this->moduleManager->isOutputEnabled('Mageplaza_SocialLogin') && !$this->oscConfig->isDisabledSocialLoginOnCheckout();
- }
}
diff --git a/Model/System/Config/Source/DeliveryTime.php b/Model/System/Config/Source/DeliveryTime.php
deleted file mode 100644
index cd1c1f2..0000000
--- a/Model/System/Config/Source/DeliveryTime.php
+++ /dev/null
@@ -1,48 +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.
- *
- * @copyright Copyright (c) 2016 Mageplaza (http://mageplaza.com/)
- * @license http://mageplaza.com/license-agreement.html
- */
-namespace Mageplaza\Osc\Model\System\Config\Source;
-
-use Magento\Framework\Model\AbstractModel;
-
-class DeliveryTime extends AbstractModel
-{
- const DAY_MONTH_YEAR = 'dd/mm/yy';
- const MONTH_DAY_YEAR = 'mm/dd/yy';
- const YEAR_MONTH_DAY = 'yy/mm/dd';
-
- public function toOptionArray()
- {
- $options = [
- [
- 'label' => __('Day/Month/Year'),
- 'value' => self::DAY_MONTH_YEAR
- ],
- [
- 'label' => __('Month/Day/Year'),
- 'value' => self::MONTH_DAY_YEAR
- ],
- [
- 'label' => __('Year/Month/Day'),
- 'value' => self::YEAR_MONTH_DAY
- ]
- ];
-
- return $options;
- }
-}
\ No newline at end of file
diff --git a/Model/System/Config/Source/PaymentMethods.php b/Model/System/Config/Source/PaymentMethods.php
index bd7e484..f83868c 100644
--- a/Model/System/Config/Source/PaymentMethods.php
+++ b/Model/System/Config/Source/PaymentMethods.php
@@ -28,50 +28,50 @@ use Magento\Framework\Option\ArrayInterface;
*/
class PaymentMethods implements ArrayInterface
{
- /**
- * @var \Magento\Payment\Helper\Data
- */
- protected $_paymentHelperData;
+ /**
+ * @var \Magento\Checkout\Model\Type\Onepage
+ */
+ protected $_modelTypeOnepage;
- /**
- * @var \Magento\Payment\Model\Config
- */
- protected $_paymentModelConfig;
+ /**
+ * @var \Magento\Payment\Helper\Data
+ */
+ protected $_paymentHelperData;
- /**
- * PaymentMethods constructor.
- * @param \Magento\Payment\Helper\Data $paymentHelperData
- * @param \Magento\Payment\Model\Config $paymentModelConfig
- */
- public function __construct(
- \Magento\Payment\Helper\Data $paymentHelperData,
- \Magento\Payment\Model\Config $paymentModelConfig
- )
- {
- $this->_paymentHelperData = $paymentHelperData;
- $this->_paymentModelConfig = $paymentModelConfig;
- }
+ /**
+ * @param \Magento\Payment\Helper\Data $paymentHelperData
+ */
+ public function __construct(
+ \Magento\Payment\Helper\Data $paymentHelperData
+ ) {
+ $this->_paymentHelperData = $paymentHelperData;
+ }
- /**
- * {@inheritdoc}
- */
- public function toOptionArray()
- {
- $options = [
- [
- 'label' => __('-- Please select --'),
- 'value' => '',
- ],
- ];
+ /**
+ * {@inheritdoc}
+ */
+ public function toOptionArray()
+ {
+ $options = [
+ [
+ 'label' => __('-- Please select --'),
+ 'value' => '',
+ ],
+ ];
- $payments = $this->_paymentModelConfig->getActiveMethods();
- foreach ($payments as $paymentCode => $paymentModel) {
- $options[$paymentCode] = array(
- 'label' => $paymentModel->getTitle(),
- 'value' => $paymentCode
- );
- }
+ $methods = $this->_paymentHelperData->getPaymentMethods();
+ foreach(array_keys($methods) as $code){
+ try{
+ $model = $this->_paymentHelperData->getMethodInstance($code);
+ $options[] = [
+ 'label' => $model->getTitle(),
+ 'value' => $model->getCode(),
+ ];
+ } catch (\Exception $e){
+ continue;
+ }
+ }
- return $options;
- }
+ return $options;
+ }
}
diff --git a/Observer/CheckoutSubmitBefore.php b/Observer/CheckoutSubmitBefore.php
index 344ba50..2a0d909 100644
--- a/Observer/CheckoutSubmitBefore.php
+++ b/Observer/CheckoutSubmitBefore.php
@@ -22,7 +22,6 @@ namespace Mageplaza\Osc\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Quote\Model\Quote;
-use Magento\Quote\Model\CustomerManagement;
/**
* Class CheckoutSubmitBefore
@@ -51,30 +50,22 @@ class CheckoutSubmitBefore implements ObserverInterface
protected $accountManagement;
/**
- * @var CustomerManagement
- */
- protected $customerManagement;
-
- /**
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\DataObject\Copy $objectCopyService
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
* @param \Magento\Customer\Api\AccountManagementInterface $accountManagement
- * @param \Magento\Quote\Model\CustomerManagement $customerManagement
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\DataObject\Copy $objectCopyService,
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
- \Magento\Customer\Api\AccountManagementInterface $accountManagement,
- CustomerManagement $customerManagement
+ \Magento\Customer\Api\AccountManagementInterface $accountManagement
)
{
$this->checkoutSession = $checkoutSession;
$this->_objectCopyService = $objectCopyService;
$this->dataObjectHelper = $dataObjectHelper;
$this->accountManagement = $accountManagement;
- $this->customerManagement = $customerManagement;
}
/**
@@ -131,9 +122,6 @@ class CheckoutSubmitBefore implements ObserverInterface
$quote->setCustomer($customer);
- /** Create customer */
- $this->customerManagement->populateCustomerInfo($quote);
-
/** Init customer address */
$customerBillingData = $billing->exportCustomerAddress();
$customerBillingData->setIsDefaultBilling(true)
diff --git a/Observer/OscConfigObserver.php b/Observer/OscConfigObserver.php
deleted file mode 100644
index 9738d9d..0000000
--- a/Observer/OscConfigObserver.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-/**
- * Copyright ? 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
-
-namespace Mageplaza\Osc\Observer;
-
-use Magento\Config\Model\ResourceModel\Config as ModelConfig;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\GiftMessage\Helper\Message;
-use Mageplaza\Osc\Helper\Config as HelperConfig;
-
-class OscConfigObserver implements \Magento\Framework\Event\ObserverInterface
-{
- /**
- * @var \Magento\Store\Model\StoreManagerInterface
- */
- protected $_storeManager;
-
- /**
- * @var HelperConfig
- */
- protected $_helperConfig;
-
- /**
- * @var ModelConfig
- */
- protected $_modelConfig;
-
- /**
- * GiftMessageConfigObserver constructor.
- *
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
- */
- public function __construct(
- HelperConfig $helperConfig,
- ModelConfig $modelConfig
- ) {
- $this->_helperConfig = $helperConfig;
- $this->_modelConfig = $modelConfig;
- }
-
- /**
- * @param \Magento\Framework\Event\Observer $observer
- */
- public function execute(\Magento\Framework\Event\Observer $observer)
- {
- $scopeId = 0;
- $isGiftMessage = !$this->_helperConfig->isDisabledGiftMessage();
- $isEnableTOC = ($this->_helperConfig->disabledPaymentTOC() || $this->_helperConfig->disabledReviewTOC());
- $this->_modelConfig
- ->saveConfig(
- Message::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER,
- $isGiftMessage,
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
- $scopeId
- )->saveConfig(
- 'checkout/options/enable_agreements',
- $isEnableTOC,
- ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
- $scopeId
- );
- }
-}
diff --git a/Observer/QuoteSubmitBefore.php b/Observer/QuoteSubmitBefore.php
index 3981962..e1a47dd 100644
--- a/Observer/QuoteSubmitBefore.php
+++ b/Observer/QuoteSubmitBefore.php
@@ -28,55 +28,51 @@ use Magento\Framework\Event\ObserverInterface;
*/
class QuoteSubmitBefore implements ObserverInterface
{
- /**
- * @var \Magento\Checkout\Model\Session
- */
- protected $checkoutSession;
+ /**
+ * @var \Magento\Checkout\Model\Session
+ */
+ protected $checkoutSession;
- /**
- * @param \Magento\Checkout\Model\Session $checkoutSession
- * @codeCoverageIgnore
- */
- public function __construct(
- \Magento\Checkout\Model\Session $checkoutSession
- )
- {
+ /**
+ * @param \Magento\Checkout\Model\Session $checkoutSession
+ * @codeCoverageIgnore
+ */
+ public function __construct(
+ \Magento\Checkout\Model\Session $checkoutSession
+ )
+ {
- $this->checkoutSession = $checkoutSession;
- }
+ $this->checkoutSession = $checkoutSession;
+ }
- /**
- * @param \Magento\Framework\Event\Observer $observer
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function execute(\Magento\Framework\Event\Observer $observer)
- {
- $order = $observer->getEvent()->getOrder();
- $quote = $observer->getEvent()->getQuote();
+ /**
+ * @param \Magento\Framework\Event\Observer $observer
+ * @return void
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ $order = $observer->getEvent()->getOrder();
+ $quote = $observer->getEvent()->getQuote();
- $oscData = $this->checkoutSession->getOscData();
- if (isset($oscData['comment'])) {
- $order->setData('osc_order_comment', $oscData['comment']);
- }
+ $oscData = $this->checkoutSession->getOscData();
+ if (isset($oscData['comment'])) {
+ $order->setData('osc_order_comment', $oscData['comment']);
+ }
- if (isset($oscData['deliveryTime'])) {
- $order->setData('osc_delivery_time', $oscData['deliveryTime']);
- }
+ $address = $quote->getShippingAddress();
+ if ($address->getUsedGiftWrap() && $address->hasData('osc_gift_wrap_amount')) {
+ $order->setData('gift_wrap_type', $address->getGiftWrapType())
+ ->setData('osc_gift_wrap_amount', $address->getOscGiftWrapAmount())
+ ->setData('base_osc_gift_wrap_amount', $address->getBaseOscGiftWrapAmount());
- $address = $quote->getShippingAddress();
- if ($address->getUsedGiftWrap() && $address->hasData('osc_gift_wrap_amount')) {
- $order->setData('gift_wrap_type', $address->getGiftWrapType())
- ->setData('osc_gift_wrap_amount', $address->getOscGiftWrapAmount())
- ->setData('base_osc_gift_wrap_amount', $address->getBaseOscGiftWrapAmount());
-
- foreach ($order->getItems() as $item) {
- $quoteItem = $quote->getItemById($item->getQuoteItemId());
- if ($quoteItem && $quoteItem->hasData('osc_gift_wrap_amount')) {
- $item->setData('osc_gift_wrap_amount', $quoteItem->getOscGiftWrapAmount())
- ->setData('base_osc_gift_wrap_amount', $quoteItem->getBaseOscGiftWrapAmount());
- }
- }
- }
- }
+ foreach ($order->getItems() as $item) {
+ $quoteItem = $quote->getItemById($item->getQuoteItemId());
+ if ($quoteItem && $quoteItem->hasData('osc_gift_wrap_amount')) {
+ $item->setData('osc_gift_wrap_amount', $quoteItem->getOscGiftWrapAmount())
+ ->setData('base_osc_gift_wrap_amount', $quoteItem->getBaseOscGiftWrapAmount());
+ }
+ }
+ }
+ }
}
diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php
index ec17588..aa648fa 100644
--- a/Setup/UpgradeData.php
+++ b/Setup/UpgradeData.php
@@ -84,13 +84,7 @@ class UpgradeData implements UpgradeDataInterface
$quoteInstaller->addAttribute('quote_address', 'used_gift_wrap', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, 'visible' => false]);
$quoteInstaller->addAttribute('quote_address', 'gift_wrap_type', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'visible' => false]);
$salesInstaller->addAttribute('order', 'gift_wrap_type', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'visible' => false]);
-
- }
-
- if (version_compare($context->getVersion(), '2.1.1') < 0) {
- $salesInstaller->addAttribute('order', 'osc_delivery_time', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false]);
}
-
$setup->endSetup();
}
}
diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml
deleted file mode 100644
index d42bf92..0000000
--- a/etc/adminhtml/events.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-/**
- * Magestore
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Magestore.com license that is
- * available through the world-wide-web at this URL:
- * http://www.magestore.com/license-agreement.html
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade this extension to newer
- * version in the future.
- *
- * @category Magestore
- * @package Magestore_OneStepCheckout
- * @copyright Copyright (c) 2012 Magestore (http://www.magestore.com/)
- * @license http://www.magestore.com/license-agreement.html
- */
--->
-<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
- <event name="admin_system_config_changed_section_osc">
- <observer name="osc_config_observer" instance="Mageplaza\Osc\Observer\OscConfigObserver" />
- </event>
-
-</config>
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 48851ca..0702fc8 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -20,96 +20,77 @@
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
-<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
- <section id="osc" translate="label comment" sortOrder="10" type="text" showInDefault="1" showInWebsite="1"
- showInStore="1">
+ <section id="osc" translate="label comment" sortOrder="10" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>One Step Checkout</label>
<tab>mageplaza</tab>
<resource>Mageplaza_Osc::config_osc</resource>
- <group id="general" translate="label comment" sortOrder="10" type="text" showInDefault="1" showInWebsite="1"
- showInStore="1">
+ <group id="general" translate="label comment" sortOrder="10" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General Configuration</label>
- <field id="is_enabled" translate="label comment" sortOrder="10" type="select" showInDefault="1"
- showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="is_enabled" translate="label comment" sortOrder="10" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Enable One Step Checkout</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
- <field id="title" translate="label comment" sortOrder="20" type="text" showInDefault="1"
- showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="title" translate="label comment" sortOrder="20" type="text" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>One Step Checkout Page Title</label>
</field>
- <field id="description" translate="label comment" sortOrder="40" type="textarea" showInDefault="1"
- showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="description" translate="label comment" sortOrder="40" type="textarea" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>One Step Checkout Description</label>
<comment>HTML allowed</comment>
</field>
- <field id="default_shipping_method" translate="label comment" sortOrder="70" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1">
+ <field id="default_shipping_method" translate="label comment" sortOrder="70" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Default Shipping Method</label>
<source_model>Mageplaza\Osc\Model\System\Config\Source\ShippingMethods</source_model>
<comment>Set default shipping method in the checkout process.</comment>
</field>
- <field id="default_payment_method" translate="label comment" sortOrder="80" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1">
+ <field id="default_payment_method" translate="label comment" sortOrder="80" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Default Payment Method</label>
<source_model>Mageplaza\Osc\Model\System\Config\Source\PaymentMethods</source_model>
<comment>Set default payment method in the checkout process.</comment>
</field>
- <field id="allow_guest_checkout" translate="label comment" sortOrder="90" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="allow_guest_checkout" translate="label comment" sortOrder="90" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Allow Guest Checkout</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Allow checking out as a guest. Guest can create an account in the checkout page.</comment>
</field>
- <field id="show_billing_address" translate="label comment" sortOrder="100" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="show_billing_address" translate="label comment" sortOrder="100" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Can Show Billing Address</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>Allow customers can billing to a different address from billing address.</comment>
</field>
- <field id="auto_detect_address" sortOrder="101" type="select" showInDefault="1" showInWebsite="1"
- showInStore="1" canRestore="1">
+ <field id="auto_detect_address" sortOrder="101" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Use Auto Suggestion Technology</label>
<source_model>Mageplaza\Osc\Model\System\Config\Source\AddressSuggest</source_model>
<comment>When customer fills address fields, it will suggest a list of full addresses.</comment>
</field>
- <field id="google_api_key" sortOrder="102" type="text" showInDefault="1" showInWebsite="1"
- showInStore="1" canRestore="1">
+ <field id="google_api_key" sortOrder="102" type="text" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Google Api Key</label>
<comment>
- You should register a new key. Get Api key <a
- href="https://developers.google.com/maps/documentation/javascript/get-api-key"
- target="_blank">here</a>
+ You should register a new key. Get Api key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank">here</a>
</comment>
<validate>required-entry</validate>
<depends>
<field id="auto_detect_address">google</field>
</depends>
</field>
- <field id="google_specific_country" sortOrder="102" type="select" showInDefault="1" showInWebsite="1"
- showInStore="1">
+ <field id="google_specific_country" sortOrder="102" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Restrict the auto suggestion for a specific country</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<depends>
<field id="auto_detect_address">google</field>
</depends>
</field>
- <field id="pca_website_key" sortOrder="102" type="text" showInDefault="1" showInWebsite="1"
- showInStore="1">
+ <field id="pca_website_key" sortOrder="102" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Capture+ Key</label>
<comment>
- To set up a Capture+ account or these keys, please visit <a
- href="http://www.pcapredict.com/en-us/address-capture-software/?utm_source=mageplaza.com&utm_medium=one-step-checkout&utm_campaign=one-step-checkout"
- target="_blank" style="margin-left:0;">Getting Started</a> page
+ To set up a Capture+ account or these keys, please visit <a href="http://www.pcapredict.com/en-us/address-capture-software/?utm_source=mageplaza.com&utm_medium=one-step-checkout&utm_campaign=one-step-checkout" target="_blank" style="margin-left:0;">Getting Started</a> page
</comment>
<depends>
<field id="auto_detect_address">pca</field>
</depends>
</field>
- <field id="pca_country_lookup" sortOrder="103" type="select" showInDefault="1" showInWebsite="1"
- showInStore="1">
+ <field id="pca_country_lookup" sortOrder="103" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>IP Country Lookup</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>The default country will be set based on location of the customer.</comment>
@@ -118,40 +99,33 @@
</depends>
</field>
</group>
- <group id="display_configuration" translate="label comment" sortOrder="20" type="text" showInDefault="1"
- showInWebsite="1" showInStore="1">
+ <group id="display_configuration" translate="label comment" sortOrder="20" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Display Configuration</label>
- <field id="is_enabled_login_link" translate="label comment" sortOrder="2" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="is_enabled_login_link" translate="label comment" sortOrder="2" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Login Link</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
- <field id="is_enabled_review_cart_section" translate="label comment" sortOrder="5" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="is_enabled_review_cart_section" translate="label comment" sortOrder="5" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Order Review Section</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>You can disable Order Review Section. It is enabled by default.</comment>
</field>
- <field id="is_show_product_image" translate="label comment" sortOrder="6" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="is_show_product_image" translate="label comment" sortOrder="6" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Product Thumbnail Image</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<depends>
<field id="is_enabled_review_cart_section">1</field>
</depends>
</field>
- <field id="show_coupon" translate="label comment" sortOrder="10" type="select" showInDefault="1"
- showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="show_coupon" translate="label comment" sortOrder="10" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Discount Code Section</label>
<source_model>Mageplaza\Osc\Model\System\Config\Source\ComponentPosition</source_model>
</field>
- <field id="is_enabled_gift_wrap" translate="label comment" sortOrder="20" type="select"
- showInDefault="1" showInWebsite="1" showInStore="1">
+ <field id="is_enabled_gift_wrap" translate="label comment" sortOrder="20" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Gift Wrap</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
- <field id="gift_wrap_type" translate="label comment" sortOrder="21" type="select" showInDefault="1"
- showInWebsite="1" showInStore="1">
+ <field id="gift_wrap_type" translate="label comment" sortOrder="21" type="select" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Calculate Method</label>
<source_model>Mageplaza\Osc\Model\System\Config\Source\Giftwrap</source_model>
<comment>To calculate gift wrap fee based on item or order.</comment>
@@ -159,110 +133,64 @@
<field id="is_enabled_gift_wrap">1</field>
</depends>
</field>
- <field id="gift_wrap_amount" translate="label comment" sortOrder="22" type="text" showInDefault="1"
- showInWebsite="1" showInStore="1">
+ <field id="gift_wrap_amount" translate="label comment" sortOrder="22" type="text" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Amount</label>
<comment>Enter the amount of gift wrap fee.</comment>
<depends>
<field id="is_enabled_gift_wrap">1</field>
</depends>
</field>
- <field id="is_enabled_comments" translate="label comment" sortOrder="30" type="select" showInDefault="1"
- showInWebsite="1" showInStore="1" canRestore="1">
+ <field id="is_enabled_comments" translate="label comment" sortOrder="30" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Order Comment</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>