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-downloadable
Observer
IsAllowedGuestCheckoutObserver.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Downloadable\Observer
;
7
8
use
Magento\Framework\Event\ObserverInterface
;
9
use
Magento\Store\Model\ScopeInterface
;
10
11
class
IsAllowedGuestCheckoutObserver
implements
ObserverInterface
12
{
16
const
XML_PATH_DISABLE_GUEST_CHECKOUT
=
'catalog/downloadable/disable_guest_checkout'
;
17
23
protected
$_scopeConfig
;
24
28
public
function
__construct
(
29
\
Magento
\Framework\
App
\Config\ScopeConfigInterface $scopeConfig
30
) {
31
$this->_scopeConfig = $scopeConfig;
32
}
33
40
public
function
execute
(\
Magento
\Framework\Event\Observer
$observer
)
41
{
42
$store
=
$observer
->getEvent()->getStore();
43
$result
=
$observer
->getEvent()->getResult();
44
45
if
(!$this->_scopeConfig->isSetFlag(
46
self::XML_PATH_DISABLE_GUEST_CHECKOUT,
47
ScopeInterface::SCOPE_STORE
,
48
$store
49
)) {
50
return
$this;
51
}
52
53
/* @var $quote \Magento\Quote\Model\Quote */
54
$quote
=
$observer
->getEvent()->getQuote();
55
56
foreach
(
$quote
->getAllItems() as
$item
) {
57
if
((
$product
=
$item
->getProduct())
58
&&
$product
->getTypeId() ==
\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE
59
) {
60
$result
->setIsAllowed(
false
);
61
break
;
62
}
63
}
64
65
return
$this;
66
}
67
}
Magento\Downloadable\Observer\IsAllowedGuestCheckoutObserver\XML_PATH_DISABLE_GUEST_CHECKOUT
const XML_PATH_DISABLE_GUEST_CHECKOUT
Definition:
IsAllowedGuestCheckoutObserver.php:16
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Framework\App
Magento\Store\Model\ScopeInterface\SCOPE_STORE
const SCOPE_STORE
Definition:
ScopeInterface.php:21
Magento\Framework\Event\ObserverInterface
Definition:
ObserverInterface.php:16
$quote
$quote
Definition:
paypal_quote.php:17
$item
$item
Definition:
partial_invoice.php:27
Magento\Downloadable\Observer
Definition:
InitOptionRendererObserver.php:6
$observer
$observer
Definition:
second_website_with_second_currency.php:38
Magento\Store\Model\ScopeInterface
Definition:
ScopeInterface.php:12
Magento\Downloadable\Observer\IsAllowedGuestCheckoutObserver
Definition:
IsAllowedGuestCheckoutObserver.php:11
Magento
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\Downloadable\Observer\IsAllowedGuestCheckoutObserver\__construct
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
Definition:
IsAllowedGuestCheckoutObserver.php:28
Magento\Downloadable\Model\Product\Type\TYPE_DOWNLOADABLE
const TYPE_DOWNLOADABLE
Definition:
Type.php:20
$store
$store
Definition:
payment_configuration_rollback.php:33
Magento\Downloadable\Observer\IsAllowedGuestCheckoutObserver\execute
execute(\Magento\Framework\Event\Observer $observer)
Definition:
IsAllowedGuestCheckoutObserver.php:40
Magento\Downloadable\Observer\IsAllowedGuestCheckoutObserver\$_scopeConfig
$_scopeConfig
Definition:
IsAllowedGuestCheckoutObserver.php:23