Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (\Magento\Payment\Model\Cart\SalesModel\Factory $salesModelFactory, \Magento\Framework\Event\ManagerInterface $eventManager, $salesModel) | |
getSalesModel () | |
addTax ($taxAmount) | |
setTax ($taxAmount) | |
getTax () | |
addDiscount ($discountAmount) | |
setDiscount ($discountAmount) | |
getDiscount () | |
addShipping ($shippingAmount) | |
setShipping ($shippingAmount) | |
getShipping () | |
addSubtotal ($subtotalAmount) | |
getSubtotal () | |
addCustomItem ($name, $qty, $amount, $identifier=null) | |
getAllItems () | |
getAmounts () | |
setTransferShippingAsItem () | |
setTransferDiscountAsItem () | |
Data Fields | |
const | AMOUNT_TAX = 'tax' |
const | AMOUNT_SHIPPING = 'shipping' |
const | AMOUNT_DISCOUNT = 'discount' |
const | AMOUNT_SUBTOTAL = 'subtotal' |
Protected Member Functions | |
_collectItemsAndAmounts () | |
_importItemsFromSalesModel () | |
_calculateCustomItemsSubtotal () | |
_setTransferFlag ($flagType, $value) | |
_setAmount ($amountType, $amount) | |
_addAmount ($amountType, $amount) | |
_getAmount ($amountType) | |
_createItemFromData ($name, $qty, $amount, $identifier=null) | |
_resetAmounts () | |
Protected Attributes | |
$_salesModel | |
$_eventManager | |
$_amounts | |
$_customItems = [] | |
$_salesModelItems = [] | |
$_transferFlags = [] | |
$_itemsCollectingRequired = true | |
Provide methods for collecting cart items information of specific sales model entity
@api
__construct | ( | \Magento\Payment\Model\Cart\SalesModel\Factory | $salesModelFactory, |
\Magento\Framework\Event\ManagerInterface | $eventManager, | ||
$salesModel | |||
) |
|
protected |
|
protected |
Calculate subtotal from custom items
Definition at line 346 of file Cart.php.
|
protected |
Collect all items, discounts, taxes, shipping to cart
Definition at line 294 of file Cart.php.
|
protected |
|
protected |
|
protected |
Import items from sales model
Definition at line 318 of file Cart.php.
|
protected |
|
protected |
|
protected |
addCustomItem | ( | $name, | |
$qty, | |||
$amount, | |||
$identifier = null |
|||
) |
Add custom item (such as discount as line item, shipping as line item, etc)
string | $name | |
int | $qty | |
float | $amount | |
string | null | $identifier |
Definition at line 237 of file Cart.php.
addDiscount | ( | $discountAmount | ) |
addShipping | ( | $shippingAmount | ) |
addSubtotal | ( | $subtotalAmount | ) |
addTax | ( | $taxAmount | ) |
getAmounts | ( | ) |
getSalesModel | ( | ) |
setDiscount | ( | $discountAmount | ) |
setShipping | ( | $shippingAmount | ) |
setTax | ( | $taxAmount | ) |
setTransferDiscountAsItem | ( | ) |
Specify that discount should be transferred as cart item
Definition at line 284 of file Cart.php.
setTransferShippingAsItem | ( | ) |
Specify that shipping should be transferred as cart item
Definition at line 273 of file Cart.php.