ModelCarts module

Item

Item that appears in the Cart for the first time and then can go to the Order

A model in the Carts module, with 31 members for templates, 27 API properties and 32 members for admin templates.

Carts\Models\Frontend\Item Carts\Models\Api\Item Carts\Models\Backend\Item Also in Carts: Cart Message
View
What Smarty and Twig templates receive. Properties in REST API responses and job payloads. What admin screen templates receive when you override them.

Templates view

Properties 30

Take no arguments.

# getCurrency()
Currency
Gets the currency of the item.
# getUnitAmountAsMoney()
Money
Gets the amount for a single unit (quantity = 1) as a Money object. Represents the value per unit before tax and discount are applied.
# getUnitDiscountAsMoney()
Money
Gets the discount for a single unit (quantity = 1) as a Money object. Represents the discount value per unit.
# getUnitTaxAsMoney()
Money
Gets the tax for a single unit (quantity = 1) as a Money object. Represents the tax value per unit.
# getUnitTotalAsMoney()
Money
Gets the total for a single unit (quantity = 1) as a Money object. Represents the final value per unit calculated as Unit Amount - Unit Discount + Unit Tax.
# getAmountAsMoney()
Money
Gets the amount for the entire quantity as a Money object. Represents the value before applying tax and discount (Unit Amount × Quantity).
# getDiscountAsMoney()
Money
Gets the discount for the entire quantity as a Money object. Represents the total discount applied (Unit Discount × Quantity).
# getTaxAsMoney()
Money
Gets the tax for the entire quantity as a Money object. Represents the total tax calculated (Unit Tax × Quantity).
# getTotalAsMoney()
Money
Gets the total for the entire quantity as a Money object. Represents the final value calculated as Amount - Discount + Tax.
# getUnitPriceAsMoney()
Money
It's an alias and deprecated! Directly use getUnitAmountAsMoney() instead.
# getItemPrice()
string
It's deprecated! Directly use getUnitAmountAsMoney() (convert to string at first) instead.
# getId()
?int
# getProductCode()
?string
# getName()
?string
# getQuantity()
?int
The number of units purchased. Quantity of the item. Integer positive (not 0) number.
# getAmount()
?string
Represents the value before applying tax and discount (Unit Amount × Quantity).
# getDiscount()
?string
Represents the total discount applied (Unit Discount × Quantity).
# getTax()
?string
Represents the total tax calculated (Unit Tax × Quantity).
# getAttributes()
array
# isAvailable()
bool
If an item is available, i.e., its product still available, or the item is not expired.
# getCreated()
?DateTime
Date the record was created.
# getModified()
?DateTime
Last modification date for the record.
# getCart()
?Cart
# getOrder()
?BaseOrder
# getProduct()
?BaseProduct
# getMessages()
?Collection<Message>
# getDiscountLogs()
?Collection<Log>
Gets discount logs associated with an item. Logs are changing only on the checkout operations, not inside the cart.
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned

Methods 1

Take arguments. The API serialises only getters that need none.

# getAttribute(string $name, ?string $default)
?string
Gets an item attribute by its name. If not specified, returns a default value. Name is case-sensitive, e.g., "color" and "Color" are two different attributes.

API & Jobs view

API & JobsEach property is a key in REST API responses and job payloads. Its name is the template getter without get, is or has. Methods that need arguments are not available here.

Properties 27

Read-only values on the record.

# currency
Currency
Gets the currency of the item.
# unitAmountAsMoney
Money
Gets the amount for a single unit (quantity = 1) as a Money object. Represents the value per unit before tax and discount are applied.
# unitDiscountAsMoney
Money
Gets the discount for a single unit (quantity = 1) as a Money object. Represents the discount value per unit.
# unitTaxAsMoney
Money
Gets the tax for a single unit (quantity = 1) as a Money object. Represents the tax value per unit.
# unitTotalAsMoney
Money
Gets the total for a single unit (quantity = 1) as a Money object. Represents the final value per unit calculated as Unit Amount - Unit Discount + Unit Tax.
# amountAsMoney
Money
Gets the amount for the entire quantity as a Money object. Represents the value before applying tax and discount (Unit Amount × Quantity).
# discountAsMoney
Money
Gets the discount for the entire quantity as a Money object. Represents the total discount applied (Unit Discount × Quantity).
# taxAsMoney
Money
Gets the tax for the entire quantity as a Money object. Represents the total tax calculated (Unit Tax × Quantity).
# totalAsMoney
Money
Gets the total for the entire quantity as a Money object. Represents the final value calculated as Amount - Discount + Tax.
# unitPriceAsMoney
Money
It's an alias and deprecated! Directly use getUnitAmountAsMoney() instead.
# itemPrice
string
It's deprecated! Directly use getUnitAmountAsMoney() (convert to string at first) instead.
# id
?int
# productCode
?string
# name
?string
# quantity
?int
The number of units purchased. Quantity of the item. Integer positive (not 0) number.
# amount
?string
Represents the value before applying tax and discount (Unit Amount × Quantity).
# discount
?string
Represents the total discount applied (Unit Discount × Quantity).
# tax
?string
Represents the total tax calculated (Unit Tax × Quantity).
# attributes
array
# available
bool
If an item is available, i.e., its product still available, or the item is not expired.
# created
?DateTime
Date the record was created.
# modified
?DateTime
Last modification date for the record.
# cart
?Cart
# order
?BaseOrder
# product
?BaseProduct
# messages
?Collection<Message>
# discountLogs
?Collection<Log>
Gets discount logs associated with an item. Logs are changing only on the checkout operations, not inside the cart.

Admin view

AdminAvailable in cdna-admin templates. Copy an admin template into your site repository to change how this record is edited.

Properties 30

Take no arguments.

# getCurrency()
Currency
Gets the currency of the item.
# getUnitAmountAsMoney()
Money
Gets the amount for a single unit (quantity = 1) as a Money object. Represents the value per unit before tax and discount are applied.
# getUnitDiscountAsMoney()
Money
Gets the discount for a single unit (quantity = 1) as a Money object. Represents the discount value per unit.
# getUnitTaxAsMoney()
Money
Gets the tax for a single unit (quantity = 1) as a Money object. Represents the tax value per unit.
# getUnitTotalAsMoney()
Money
Gets the total for a single unit (quantity = 1) as a Money object. Represents the final value per unit calculated as Unit Amount - Unit Discount + Unit Tax.
# getAmountAsMoney()
Money
Gets the amount for the entire quantity as a Money object. Represents the value before applying tax and discount (Unit Amount × Quantity).
# getDiscountAsMoney()
Money
Gets the discount for the entire quantity as a Money object. Represents the total discount applied (Unit Discount × Quantity).
# getTaxAsMoney()
Money
Gets the tax for the entire quantity as a Money object. Represents the total tax calculated (Unit Tax × Quantity).
# getTotalAsMoney()
Money
Gets the total for the entire quantity as a Money object. Represents the final value calculated as Amount - Discount + Tax.
# getUnitPriceAsMoney()
Money
It's an alias and deprecated! Directly use getUnitAmountAsMoney() instead.
# getItemPrice()
string
It's deprecated! Directly use getUnitAmountAsMoney() (convert to string at first) instead.
# getId()
?int
# getProductCode()
?string
# getName()
?string
# getQuantity()
?int
The number of units purchased. Quantity of the item. Integer positive (not 0) number.
# getAmount()
?string
Represents the value before applying tax and discount (Unit Amount × Quantity).
# getDiscount()
?string
Represents the total discount applied (Unit Discount × Quantity).
# getTax()
?string
Represents the total tax calculated (Unit Tax × Quantity).
# getAttributes()
array
# isAvailable()
bool
If an item is available, i.e., its product still available, or the item is not expired.
# getCreated()
?DateTime
Date the record was created.
# getModified()
?DateTime
Last modification date for the record.
# getCart()
?Cart
# getOrder()
?BaseOrder
# getProduct()
?BaseProduct
# getMessages()
?Collection<Message>
# getDiscountLogs()
?Collection<Log>
Gets discount logs associated with an item. Logs are changing only on the checkout operations, not inside the cart.
# isNewRecord() Not in API & Jobs
bool
Check if the record is a new record
# isHierarchicalModel() Not in API & Jobs
bool
Check whether a model is a hierarchical model, i.e. can have children
# isVersionedModel() Not in API & Jobs
bool
Check whether a model is versioned

Methods 2

Take arguments. The API serialises only getters that need none.

# getAttribute(string $name, ?string $default)
?string
Gets an item attribute by its name. If not specified, returns a default value. Name is case-sensitive, e.g., "color" and "Color" are two different attributes.
# getImage(int $width, int $height) Admin only
Image
Get the image for the item. If the item is linked to a product with an image, it returns the product image. Otherwise, it returns a placeholder image.