Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Data Class Reference
Inheritance diagram for Data:
AbstractHelper

Public Member Functions

 __construct (\Magento\Framework\App\Helper\Context $context, \Magento\Checkout\Model\Session $checkoutSession)
 
 getQuote ()
 
 getMaximumQty ()
 
 isMultishippingCheckoutAvailable ()
 
- Public Member Functions inherited from AbstractHelper
 __construct (Context $context)
 
 isModuleOutputEnabled ($moduleName=null)
 

Data Fields

const XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE = 'multishipping/options/checkout_multiple'
 
const XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY = 'multishipping/options/checkout_multiple_maximum_qty'
 

Protected Attributes

 $checkoutSession
 
- Protected Attributes inherited from AbstractHelper
 $_moduleName
 
 $_request
 
 $_moduleManager
 
 $_logger
 
 $_urlBuilder
 
 $_httpHeader
 
 $_eventManager
 
 $_remoteAddress
 
 $urlEncoder
 
 $urlDecoder
 
 $scopeConfig
 
 $_cacheConfig
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHelper
 _getRequest ()
 
 _getModuleName ()
 
 _getUrl ($route, $params=[])
 

Detailed Description

Data helper

Definition at line 12 of file Data.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Helper\Context  $context,
\Magento\Checkout\Model\Session  $checkoutSession 
)

Construct

Parameters
\Magento\Framework\App\Helper\Context$context
\Magento\Checkout\Model\Session$checkoutSession

Definition at line 35 of file Data.php.

38  {
39  $this->checkoutSession = $checkoutSession;
40  parent::__construct($context);
41  }

Member Function Documentation

◆ getMaximumQty()

getMaximumQty ( )

Get maximum quantity allowed for shipping to multiple addresses

Returns
int

Definition at line 58 of file Data.php.

59  {
60  return (int)$this->scopeConfig->getValue(
61  self::XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY,
62  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
63  );
64  }

◆ getQuote()

getQuote ( )

Retrieve checkout quote

Returns
\Magento\Quote\Model\Quote

Definition at line 48 of file Data.php.

49  {
50  return $this->checkoutSession->getQuote();
51  }

◆ isMultishippingCheckoutAvailable()

isMultishippingCheckoutAvailable ( )

Check if multishipping checkout is available There should be a valid quote in checkout session. If not, only the config value will be returned

Returns
bool

Definition at line 72 of file Data.php.

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  }
$quote

Field Documentation

◆ $checkoutSession

$checkoutSession
protected

Definition at line 27 of file Data.php.

◆ XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE

const XML_PATH_CHECKOUT_MULTIPLE_AVAILABLE = 'multishipping/options/checkout_multiple'

Definition at line 18 of file Data.php.

◆ XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY

const XML_PATH_CHECKOUT_MULTIPLE_MAXIMUM_QUANTITY = 'multishipping/options/checkout_multiple_maximum_qty'

Definition at line 20 of file Data.php.


The documentation for this class was generated from the following file: