◆ __construct()
- Parameters
-
\Magento\Framework\App\Helper\Context | $context | |
\Magento\Checkout\Model\Cart | $checkoutCart | |
\Magento\Checkout\Model\Session | $checkoutSession | @codeCoverageIgnore |
Definition at line 46 of file Cart.php.
51 $this->_checkoutCart = $checkoutCart;
52 $this->_checkoutSession = $checkoutSession;
53 parent::__construct($context);
◆ getAddUrl()
getAddUrl |
( |
|
$product, |
|
|
|
$additional = [] |
|
) |
| |
Retrieve url for add product to cart
- Parameters
-
\Magento\Catalog\Model\Product | $product | |
array | $additional | |
- Returns
- string
Definition at line 74 of file Cart.php.
76 if (isset($additional[
'useUencPlaceholder'])) {
78 unset($additional[
'useUencPlaceholder']);
80 $uenc = $this->urlEncoder->encode($this->_urlBuilder->getCurrentUrl());
86 $urlParamName => $uenc,
87 'product' =>
$product->getEntityId(),
91 if (!empty($additional)) {
92 $routeParams = array_merge($routeParams, $additional);
96 $routeParams[
'_scope'] =
$product->getUrlDataObject()->getStoreId();
97 $routeParams[
'_scope_to_url'] =
true;
100 if ($this->
_getRequest()->getRouteName() ==
'checkout' 101 && $this->
_getRequest()->getControllerName() ==
'cart' 103 $routeParams[
'in_cart'] = 1;
106 return $this->
_getUrl(
'checkout/cart/add', $routeParams);
const PARAM_NAME_URL_ENCODED
_getUrl($route, $params=[])
◆ getCart()
Retrieve cart instance
- Returns
- \Magento\Checkout\Model\Cart @codeCoverageIgnore
Definition at line 62 of file Cart.php.
◆ getCartUrl()
Retrieve shopping cart url
- Returns
- string @codeCoverageIgnore
Definition at line 147 of file Cart.php.
149 return $this->
_getUrl(
'checkout/cart');
_getUrl($route, $params=[])
◆ getDeletePostJson()
getDeletePostJson |
( |
|
$item | ) |
|
Get post parameters for delete from cart
- Parameters
-
\Magento\Quote\Model\Quote\Item\AbstractItem | $item | |
- Returns
- string
Definition at line 130 of file Cart.php.
135 if (!$this->_request->isAjax()) {
138 return json_encode([
'action' =>
$url,
'data' =>
$data]);
const PARAM_NAME_URL_ENCODED
_getUrl($route, $params=[])
◆ getIsVirtualQuote()
Check quote for virtual products only
- Returns
- bool @SuppressWarnings(PHPMD.BooleanGetMethodName) @codeCoverageIgnore
Definition at line 203 of file Cart.php.
205 return $this->
getQuote()->isVirtual();
◆ getItemsCount()
Get shopping cart items count
- Returns
- int @codeCoverageIgnore
Definition at line 169 of file Cart.php.
171 return $this->
getCart()->getItemsCount();
◆ getItemsQty()
Get shopping cart summary qty
- Returns
- int|float @codeCoverageIgnore
Definition at line 180 of file Cart.php.
182 return $this->
getCart()->getItemsQty();
◆ getQuote()
Retrieve current quote instance
- Returns
- \Magento\Quote\Model\Quote @codeCoverageIgnore
Definition at line 158 of file Cart.php.
160 return $this->_checkoutSession->getQuote();
◆ getRemoveUrl()
Retrieve url for remove product from cart
- Parameters
-
\Magento\Quote\Model\Quote\Item\AbstractItem | $item | |
- Returns
- string
Definition at line 115 of file Cart.php.
118 'id' =>
$item->getId(),
const PARAM_NAME_BASE64_URL
_getUrl($route, $params=[])
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
◆ getShouldRedirectToCart()
getShouldRedirectToCart |
( |
|
$store = null | ) |
|
Checks if customer should be redirected to shopping cart after adding a product
- Parameters
-
int | string | \Magento\Store\Model\Store | $store | |
- Returns
- bool @SuppressWarnings(PHPMD.BooleanGetMethodName) @codeCoverageIgnore
Definition at line 216 of file Cart.php.
218 return $this->scopeConfig->isSetFlag(
219 self::XML_PATH_REDIRECT_TO_CART,
◆ getSummaryCount()
Get shopping cart items summary (include config settings)
- Returns
- int|float @codeCoverageIgnore
Definition at line 191 of file Cart.php.
193 return $this->
getCart()->getSummaryQty();
◆ $_checkoutCart
◆ $_checkoutSession
◆ COUPON_CODE_MAX_LENGTH
const COUPON_CODE_MAX_LENGTH = 255 |
Maximal coupon code length according to database table definitions (longer codes are truncated)
Definition at line 28 of file Cart.php.
◆ DELETE_URL
const DELETE_URL = 'checkout/cart/delete' |
Path to controller to delete item from cart
Definition at line 18 of file Cart.php.
◆ XML_PATH_REDIRECT_TO_CART
const XML_PATH_REDIRECT_TO_CART = 'checkout/cart/redirect_to_cart' |
Path for redirect to cart
Definition at line 23 of file Cart.php.
The documentation for this class was generated from the following file:
- vendor/magento/module-checkout/Helper/Cart.php