forked from PAYONE-GmbH/magento-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckout.php
88 lines (81 loc) · 2.76 KB
/
Checkout.php
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
<?php
/**
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 5
*
* @category Payone
* @package Payone_Magento2_Plugin
* @author FATCHIP GmbH <support@fatchip.de>
* @copyright 2003 - 2016 Payone GmbH
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License
* @link http://www.payone.de
*/
namespace Payone\Core\Helper;
use Magento\Quote\Model\Quote;
use Magento\Checkout\Model\Type\Onepage;
/**
* Helper class for everything that has to do with the checkout
*/
class Checkout extends \Payone\Core\Helper\Base
{
/**
* Checkout session
*
* @var \Magento\Customer\Model\Session
*/
protected $customerSession;
/**
* @var \Magento\Checkout\Helper\Data
*/
protected $checkoutData;
/**
* Constructor
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Helper\Data $checkoutData
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Customer\Model\Session $customerSession,
\Magento\Checkout\Helper\Data $checkoutData
) {
parent::__construct($context, $storeManager);
$this->customerSession = $customerSession;
$this->checkoutData = $checkoutData;
}
/**
* Get checkout method
*
* @param Quote $oQuote
* @return string
*/
public function getCurrentCheckoutMethod(Quote $oQuote)
{
if ($this->customerSession->isLoggedIn()) {
return Onepage::METHOD_CUSTOMER;
}
if (!$oQuote->getCheckoutMethod()) {
if ($this->checkoutData->isAllowedGuestCheckout($oQuote)) {
$oQuote->setCheckoutMethod(Onepage::METHOD_GUEST);
} else {
$oQuote->setCheckoutMethod(Onepage::METHOD_REGISTER);
}
}
return $oQuote->getCheckoutMethod();
}
}