8
8
use Magento \Customer \Api \Data \CustomerInterface as CustomerDataObject ;
9
9
use Magento \Customer \Model \AccountManagement ;
10
10
use Magento \Paypal \Model \Config as PaypalConfig ;
11
- use Magento \Paypal \Model \Express \Checkout \Quote as PaypalQuote ;
12
11
use Magento \Sales \Model \Order \Email \Sender \OrderSender ;
13
12
use Magento \Quote \Model \Quote \Address ;
14
13
use Magento \Framework \DataObject ;
@@ -254,11 +253,6 @@ class Checkout
254
253
*/
255
254
protected $ orderSender ;
256
255
257
- /**
258
- * @var PaypalQuote
259
- */
260
- protected $ paypalQuote ;
261
-
262
256
/**
263
257
* @var \Magento\Quote\Api\CartRepositoryInterface
264
258
*/
@@ -296,7 +290,6 @@ class Checkout
296
290
* @param \Magento\Framework\Message\ManagerInterface $messageManager
297
291
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
298
292
* @param AccountManagement $accountManagement
299
- * @param PaypalQuote $paypalQuote
300
293
* @param OrderSender $orderSender
301
294
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
302
295
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
@@ -326,7 +319,6 @@ public function __construct(
326
319
\Magento \Framework \Message \ManagerInterface $ messageManager ,
327
320
\Magento \Customer \Api \CustomerRepositoryInterface $ customerRepository ,
328
321
AccountManagement $ accountManagement ,
329
- PaypalQuote $ paypalQuote ,
330
322
OrderSender $ orderSender ,
331
323
\Magento \Quote \Api \CartRepositoryInterface $ quoteRepository ,
332
324
\Magento \Quote \Model \Quote \TotalsCollector $ totalsCollector ,
@@ -353,7 +345,6 @@ public function __construct(
353
345
$ this ->_messageManager = $ messageManager ;
354
346
$ this ->orderSender = $ orderSender ;
355
347
$ this ->_accountManagement = $ accountManagement ;
356
- $ this ->paypalQuote = $ paypalQuote ;
357
348
$ this ->quoteRepository = $ quoteRepository ;
358
349
$ this ->totalsCollector = $ totalsCollector ;
359
350
$ this ->_customerSession = isset ($ params ['session ' ])
@@ -620,7 +611,7 @@ public function returnFromPaypal($token)
620
611
->callGetExpressCheckoutDetails ();
621
612
$ quote = $ this ->_quote ;
622
613
623
- $ this ->_ignoreAddressValidation ();
614
+ $ this ->ignoreAddressValidation ();
624
615
625
616
// import shipping address
626
617
$ exportedShippingAddress = $ this ->_api ->getExportedShippingAddress ();
@@ -708,7 +699,7 @@ public function prepareOrderReview($token = null)
708
699
$ this ->_quote ->setMayEditShippingMethod (
709
700
'' == $ this ->_quote ->getPayment ()->getAdditionalInformation (self ::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD )
710
701
);
711
- $ this ->_ignoreAddressValidation ();
702
+ $ this ->ignoreAddressValidation ();
712
703
$ this ->_quote ->collectTotals ();
713
704
$ this ->quoteRepository ->save ($ this ->_quote );
714
705
}
@@ -763,7 +754,7 @@ public function updateShippingMethod($methodCode)
763
754
$ shippingAddress = $ this ->_quote ->getShippingAddress ();
764
755
if (!$ this ->_quote ->getIsVirtual () && $ shippingAddress ) {
765
756
if ($ methodCode != $ shippingAddress ->getShippingMethod ()) {
766
- $ this ->_ignoreAddressValidation ();
757
+ $ this ->ignoreAddressValidation ();
767
758
$ shippingAddress ->setShippingMethod ($ methodCode )->setCollectShippingRates (true );
768
759
$ this ->_quote ->collectTotals ();
769
760
$ this ->quoteRepository ->save ($ this ->_quote );
@@ -786,31 +777,14 @@ public function place($token, $shippingMethodCode = null)
786
777
$ this ->updateShippingMethod ($ shippingMethodCode );
787
778
}
788
779
789
- $ isNewCustomer = false ;
790
- switch ($ this ->getCheckoutMethod ()) {
791
- case \Magento \Checkout \Model \Type \Onepage::METHOD_GUEST :
792
- $ this ->_prepareGuestQuote ();
793
- break ;
794
- case \Magento \Checkout \Model \Type \Onepage::METHOD_REGISTER :
795
- $ this ->_prepareNewCustomerQuote ();
796
- $ isNewCustomer = true ;
797
- break ;
798
- default :
799
- $ this ->_prepareCustomerQuote ();
800
- break ;
780
+ if ($ this ->getCheckoutMethod () == \Magento \Checkout \Model \Type \Onepage::METHOD_GUEST ) {
781
+ $ this ->prepareGuestQuote ();
801
782
}
802
783
803
- $ this ->_ignoreAddressValidation ();
784
+ $ this ->ignoreAddressValidation ();
804
785
$ this ->_quote ->collectTotals ();
805
786
$ order = $ this ->quoteManagement ->submit ($ this ->_quote );
806
787
807
- if ($ isNewCustomer ) {
808
- try {
809
- $ this ->_involveNewCustomer ();
810
- } catch (\Exception $ e ) {
811
- $ this ->_logger ->critical ($ e );
812
- }
813
- }
814
788
if (!$ order ) {
815
789
return ;
816
790
}
@@ -843,7 +817,7 @@ public function place($token, $shippingMethodCode = null)
843
817
*
844
818
* @return void
845
819
*/
846
- private function _ignoreAddressValidation ()
820
+ private function ignoreAddressValidation ()
847
821
{
848
822
$ this ->_quote ->getBillingAddress ()->setShouldIgnoreValidation (true );
849
823
if (!$ this ->_quote ->getIsVirtual ()) {
@@ -1109,62 +1083,6 @@ protected function _matchShippingMethodCode(Address $address, $selectedCode)
1109
1083
return '' ;
1110
1084
}
1111
1085
1112
- /**
1113
- * Prepare quote for guest checkout order submit
1114
- *
1115
- * @return $this
1116
- */
1117
- protected function _prepareGuestQuote ()
1118
- {
1119
- $ quote = $ this ->_quote ;
1120
- $ quote ->setCustomerId (null )
1121
- ->setCustomerEmail ($ quote ->getBillingAddress ()->getEmail ())
1122
- ->setCustomerIsGuest (true )
1123
- ->setCustomerGroupId (\Magento \Customer \Model \Group::NOT_LOGGED_IN_ID );
1124
- return $ this ;
1125
- }
1126
-
1127
- /**
1128
- * Prepare quote for customer registration and customer order submit
1129
- * and restore magento customer data from quote
1130
- *
1131
- * @return void
1132
- */
1133
- protected function _prepareNewCustomerQuote ()
1134
- {
1135
- $ this ->paypalQuote ->prepareQuoteForNewCustomer ($ this ->_quote );
1136
- }
1137
-
1138
- /**
1139
- * Prepare quote for customer order submit
1140
- *
1141
- * @return void
1142
- */
1143
- protected function _prepareCustomerQuote ()
1144
- {
1145
- $ this ->paypalQuote ->prepareRegisteredCustomerQuote ($ this ->_quote , $ this ->_customerSession ->getCustomerId ());
1146
- }
1147
-
1148
- /**
1149
- * Involve new customer to system
1150
- *
1151
- * @return $this
1152
- */
1153
- protected function _involveNewCustomer ()
1154
- {
1155
- $ customer = $ this ->_quote ->getCustomer ();
1156
- $ confirmationStatus = $ this ->_accountManagement ->getConfirmationStatus ($ customer ->getId ());
1157
- if ($ confirmationStatus === AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED ) {
1158
- $ this ->_messageManager ->addSuccess (
1159
- __ ('Thank you for registering with Main Website Store. ' )
1160
- );
1161
- } else {
1162
- $ this ->getCustomerSession ()->regenerateId ();
1163
- $ this ->getCustomerSession ()->loginById ($ customer ->getId ());
1164
- }
1165
- return $ this ;
1166
- }
1167
-
1168
1086
/**
1169
1087
* Create payment redirect url
1170
1088
* @param bool|null $button
@@ -1218,4 +1136,19 @@ private function setShippingOptions(PaypalCart $cart, Address $address = null)
1218
1136
}
1219
1137
}
1220
1138
}
1139
+
1140
+ /**
1141
+ * Prepare quote for guest checkout order submit
1142
+ *
1143
+ * @return $this
1144
+ */
1145
+ protected function prepareGuestQuote ()
1146
+ {
1147
+ $ quote = $ this ->_quote ;
1148
+ $ quote ->setCustomerId (null )
1149
+ ->setCustomerEmail ($ quote ->getBillingAddress ()->getEmail ())
1150
+ ->setCustomerIsGuest (true )
1151
+ ->setCustomerGroupId (\Magento \Customer \Model \Group::NOT_LOGGED_IN_ID );
1152
+ return $ this ;
1153
+ }
1221
1154
}
0 commit comments