Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data.php
Go to the documentation of this file.
1 <?php
8 
13 {
14  /*
15  * Xml paths for multishipping checkout
16  *
17  **/
18  const XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE = 'multishipping/options/checkout_multiple';
19 
20  const XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY = 'multishipping/options/checkout_multiple_maximum_qty';
21 
27  protected $checkoutSession;
28 
35  public function __construct(
36  \Magento\Framework\App\Helper\Context $context,
37  \Magento\Checkout\Model\Session $checkoutSession
38  ) {
39  $this->checkoutSession = $checkoutSession;
40  parent::__construct($context);
41  }
42 
48  public function getQuote()
49  {
50  return $this->checkoutSession->getQuote();
51  }
52 
58  public function getMaximumQty()
59  {
60  return (int)$this->scopeConfig->getValue(
61  self::XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY,
62  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
63  );
64  }
65 
73  {
74  $quote = $this->getQuote();
75  $isMultiShipping = $this->scopeConfig->isSetFlag(
76  self::XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE,
77  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
78  );
79  if (!$quote || !$quote->hasItems()) {
80  return $isMultiShipping;
81  }
82  return $isMultiShipping && !$quote->hasItemsWithDecimalQty() && $quote->validateMinimumAmount(
83  true
84  ) &&
85  $quote->getItemsSummaryQty() - $quote->getItemVirtualQty() > 0 &&
86  $quote->getItemsSummaryQty() <= $this->getMaximumQty();
87  }
88 }
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Checkout\Model\Session $checkoutSession)
Definition: Data.php:35
const XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY
Definition: Data.php:20
$quote
const XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE
Definition: Data.php:18