9
9
use Magento \Framework \App \Action \Action as AppAction ;
10
10
use Magento \Framework \App \Action \HttpGetActionInterface ;
11
11
use Magento \Framework \App \Action \HttpPostActionInterface ;
12
+ use Magento \Framework \App \ObjectManager ;
13
+ use Magento \Quote \Api \CartRepositoryInterface ;
12
14
use Magento \Quote \Api \Data \CartInterface ;
13
15
14
16
/**
@@ -98,6 +100,11 @@ abstract class AbstractExpress extends AppAction implements
98
100
*/
99
101
protected $ _customerUrl ;
100
102
103
+ /**
104
+ * @var CartRepositoryInterface
105
+ */
106
+ private $ quoteRepository ;
107
+
101
108
/**
102
109
* @param \Magento\Framework\App\Action\Context $context
103
110
* @param \Magento\Customer\Model\Session $customerSession
@@ -107,6 +114,7 @@ abstract class AbstractExpress extends AppAction implements
107
114
* @param \Magento\Framework\Session\Generic $paypalSession
108
115
* @param \Magento\Framework\Url\Helper\Data $urlHelper
109
116
* @param \Magento\Customer\Model\Url $customerUrl
117
+ * @param CartRepositoryInterface $quoteRepository
110
118
*/
111
119
public function __construct (
112
120
\Magento \Framework \App \Action \Context $ context ,
@@ -116,7 +124,8 @@ public function __construct(
116
124
\Magento \Paypal \Model \Express \Checkout \Factory $ checkoutFactory ,
117
125
\Magento \Framework \Session \Generic $ paypalSession ,
118
126
\Magento \Framework \Url \Helper \Data $ urlHelper ,
119
- \Magento \Customer \Model \Url $ customerUrl
127
+ \Magento \Customer \Model \Url $ customerUrl ,
128
+ CartRepositoryInterface $ quoteRepository = null
120
129
) {
121
130
$ this ->_customerSession = $ customerSession ;
122
131
$ this ->_checkoutSession = $ checkoutSession ;
@@ -128,6 +137,7 @@ public function __construct(
128
137
parent ::__construct ($ context );
129
138
$ parameters = ['params ' => [$ this ->_configMethod ]];
130
139
$ this ->_config = $ this ->_objectManager ->create ($ this ->_configType , $ parameters );
140
+ $ this ->quoteRepository = $ quoteRepository ?: ObjectManager::getInstance ()->get (CartRepositoryInterface::class);
131
141
}
132
142
133
143
/**
@@ -233,7 +243,12 @@ protected function _getCheckoutSession()
233
243
protected function _getQuote ()
234
244
{
235
245
if (!$ this ->_quote ) {
236
- $ this ->_quote = $ this ->_getCheckoutSession ()->getQuote ();
246
+ if ($ this ->_getSession ()->getQuoteId ()) {
247
+ $ this ->_quote = $ this ->quoteRepository ->get ($ this ->_getSession ()->getQuoteId ());
248
+ $ this ->_getCheckoutSession ()->replaceQuote ($ this ->_quote );
249
+ } else {
250
+ $ this ->_quote = $ this ->_getCheckoutSession ()->getQuote ();
251
+ }
237
252
}
238
253
return $ this ->_quote ;
239
254
}
@@ -243,7 +258,7 @@ protected function _getQuote()
243
258
*/
244
259
public function getCustomerBeforeAuthUrl ()
245
260
{
246
- return ;
261
+ return null ;
247
262
}
248
263
249
264
/**
0 commit comments