Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-quote
Model
ChangeQuoteControl.php
Go to the documentation of this file.
1
<?php
7
declare(strict_types=1);
8
9
namespace
Magento\Quote\Model
;
10
11
use
Magento\Authorization\Model\UserContextInterface
;
12
use
Magento\Quote\Api\ChangeQuoteControlInterface
;
13
use
Magento\Quote\Api\Data\CartInterface
;
14
18
class
ChangeQuoteControl
implements
ChangeQuoteControlInterface
19
{
23
private
$userContext;
24
28
public
function
__construct
(
UserContextInterface
$userContext)
29
{
30
$this->userContext = $userContext;
31
}
32
36
public
function
isAllowed
(
CartInterface
$quote
): bool
37
{
38
switch
($this->userContext->getUserType()) {
39
case
UserContextInterface::USER_TYPE_CUSTOMER
:
40
$isAllowed
= (
$quote
->getCustomerId() == $this->userContext->getUserId());
41
break
;
42
case
UserContextInterface::USER_TYPE_GUEST
:
43
$isAllowed
= (
$quote
->getCustomerId() ===
null
);
44
break
;
45
case
UserContextInterface::USER_TYPE_ADMIN
:
46
case
UserContextInterface::USER_TYPE_INTEGRATION
:
47
$isAllowed
=
true
;
48
break
;
49
default
:
50
$isAllowed
=
false
;
51
}
52
53
return
$isAllowed
;
54
}
55
}
Magento\Quote\Api\Data\CartInterface
Definition:
CartInterface.php:13
Magento\Authorization\Model\UserContextInterface\USER_TYPE_GUEST
const USER_TYPE_GUEST
Definition:
UserContextInterface.php:23
Magento\Quote\Model
Definition:
MaskedQuoteIdToQuoteIdTest.php:8
Magento\Quote\Model\ChangeQuoteControl
Definition:
ChangeQuoteControl.php:18
$quote
$quote
Definition:
paypal_quote.php:17
Magento\Authorization\Model\UserContextInterface
Definition:
UserContextInterface.php:15
Magento\Quote\Model\ChangeQuoteControl\isAllowed
isAllowed(CartInterface $quote)
Definition:
ChangeQuoteControl.php:36
Magento\Quote\Api\ChangeQuoteControlInterface
Definition:
ChangeQuoteControlInterface.php:16
$isAllowed
$isAllowed
Definition:
get.php:20
Magento\Quote\Model\ChangeQuoteControl\__construct
__construct(UserContextInterface $userContext)
Definition:
ChangeQuoteControl.php:28
Magento\Authorization\Model\UserContextInterface\USER_TYPE_ADMIN
const USER_TYPE_ADMIN
Definition:
UserContextInterface.php:21
Magento\Authorization\Model\UserContextInterface\USER_TYPE_INTEGRATION
const USER_TYPE_INTEGRATION
Definition:
UserContextInterface.php:20
Magento\Authorization\Model\UserContextInterface\USER_TYPE_CUSTOMER
const USER_TYPE_CUSTOMER
Definition:
UserContextInterface.php:22