\Commerce\Carts\Current
Templating
Global Functions
Website
\Components\Website\Designs \Components\Website\Media \Components\Website\Pages \Components\Website\Pages\Forms \Components\Website\Posts \Components\Website\Posts\Categories
Customers
\Components\Customers\Contacts \Components\Customers\Contacts\Relationships \Components\Customers\Contacts\Relationships\Types \Components\Customers\Groups
Marketing
\Components\Marketing\EmailMarketing \Components\Marketing\Events \Components\Marketing\Events\Attendees \Components\Marketing\Events\Categories \Components\Marketing\Events\Locations
Commerce
\Components\Commerce\Carts \Components\Commerce\Carts\Current
METHODS
\Components\Commerce\Configuration\PaymentMethods \Components\Commerce\Configuration\ShippingMethods \Components\Commerce\Discounts \Components\Commerce\Products \Components\Commerce\Products\Brands \Components\Commerce\Products\Categories \Components\Commerce\Products\Inventory \Components\Commerce\Sales \Components\Commerce\Sales\Items \Components\Commerce\Sales\Receipts \Components\Commerce\Sales\Receipts\Allocations
Settings
\Components\Settings\Administrators \Components\Settings\CustomFields \Components\Settings\Domains
Other Apps
\Components\Website\Comments \Components\Commerce\Affiliates \Components\Commerce\Affiliates\Administrators \Components\Commerce\Affiliates\Commissions \Components\Commerce\Affiliates\Payments \Components\Commerce\RecurringSales \Components\Commerce\RecurringSales\StoredCards
Framework
\Framework\Caching \Framework\Data\Util \Framework\DOM\CurrentContext \Framework\HTML\Bleacher \Framework\HTML\Converters \Framework\HTTP\Cookies \Framework\HTTP\Redirection \Framework\HTTP\Request \Framework\HTTP\Session \Framework\HTTP\UserAgent \Framework\I18N\CompanyTypes \Framework\I18N\Countries \Framework\I18N\Languages \Framework\Network\GeoIP

Current

Access and modify the shopping cart of the current visitor.

Methods

Invoke via \Components\Commerce\Carts\Current::method()
Click a method name to copy it.
void addProduct($arrOptions)
Adds a product to the shopping cart

product_id => The id of the product to add to the cart product_quantity => The quantity to add to the cart product_order_options_user => User selected options when ordering a product product_price => Price disable_merge => When true, if an identical product already exists in the cart, no merge will occur bought_for_contact_id => Allows the product to be linked to a different contact product_title => Used only if no product_id set product_sales_description => Sales invoice description ]
Parameters
$arrOptions
mixed
void addProducts($arrAllOptions)
Adds products to the shopping cart

[ [ product_id => The id of the product to add to the cart product_quantity => The quantity to add to the cart product_order_options_user => User selected options when ordering a product product_price => Price disable_merge => When true, if an identical product already exists in the cart, no merge will occur bought_for_contact_id => Allows the product to be linked to a different contact product_title => Used only if no product_id set product_sales_description => Sales invoice description ], ... ]
Parameters
$arrAllOptions
mixed
array calculateDimensionsMM($iCubicBreak, $fWeightBreak)
Returns the shipment items
Parameters
$iCubicBreak
mixed
$fWeightBreak
mixed
Return
array
void clear()
Clears the cart
void clearItems()
Clears the cart
void convertPostedProductOptionsToAssoc($iProductId, $arrOrderOptionsPost)
Parameters
$iProductId
mixed
$arrOrderOptionsPost
mixed
array getAllDetailed()
Returns the shopping cart as an array with the details of the products, calculated tax and shipping
Return
Products in shopping cart
string getComments()
Returns any comments the customer may have on their order
Return
string
int getCount()
Returns the number of item rows in the shopping cart
Return
Number of rows
int getCountProducts()
Returns the total quantity of products in the shopping cart
Return
Number of products
string getCountry()
Returns the country of the contact uses this cart
Return
string
string getCurrencyId()
Returns the current currency id
Return
string
array getDiscounts()
Returns an array of discounts for this order
Return
Discounts
bool getIsGuestCheckoutDisabled()
Returns whether or not the 'guest checkout' option is disabled for cart.

This is derived from the products in the cart.
Return
bool
bool getIsShippingRequired()
Returns whether shipping is required for the products currently in the cart
Return
bool
void getIsSubmittable()
Returns whether the cart is submittable or not
float getOrderMinimumAmount()
Retrieves the order minimum value as configured in the config item
Return
float
\Components\Commerce\Configuration\PaymentMethods\Methods\ABC getPaymentMethodClass()
Returns the payment method used when the order is processed
Return
Payment method
int getProductOrderedQuantity($iProductId, $iContactId)
Retrieves the ordered quantity for a specific product for a specific contact
Parameters
$iProductId
mixed
$iContactId
mixed
Return
int
void getRowProductId($iCartRowId)
Returns the product_id for a particular row of items in the cart
Parameters
$iCartRowId
mixed
string getShippingColumn($strColumn)
Returns a column of the orders shipping details
Parameters
$strColumn
mixed
Return
Value
array getShippingErrors()
Returns an array of any errors encountered when calculating shipping
Return
array
void getShippingMethodClass()
array getShippingMethodConfiguration()
Returns the configuration options for the shipping method
Return
array
string getStep($bHasProducts, $bContact, $bContactUpdate, $bShipping)
Returns the page of the recommended step in the ordering process
Parameters
$bHasProducts
mixed
$bContact
mixed
$bContactUpdate
mixed
$bShipping
mixed
Return
Page id
float getTotal($bIncludeShipping, $bIncludeDiscounts)
Returns the total dollar value of the items in the shopping cart
Parameters
$bIncludeShipping
mixed
$bIncludeDiscounts
mixed
Return
Total amount
float getTotalProducts()
Returns the dollar value total of just the products in the cart
Return
Total for products
float getTotalShipping()
Returns the dollar value total of the shipping
Return
Total shipping
float getTotalTax()
Returns the dollar value total tax for the items in the cart
Return
Total tax
string getTotalTaxLabel()
Returns the label for the tax rate - eg: 'GST'
Return
string
string getTotalTaxPercent()
Returns the tax rate - eg: '10%'
Return
string
int getTotalWeight()
Returns the total weight for the cart.
Return
int
bool hasDiscountFreeShipping()
Returns whether the cart has free shipping
Return
bool
bool hasDiscounts()
Returns whether the cart has discounts
Return
bool
boolean isCustomItem($arrCartItem)
Determines if a cart item is custom or if corresponds to a product
Parameters
$arrCartItem
mixed
Return
boolean
bool isProductCategoryInCart($iProductCategoryId)
Returns whether or not a product has been added to the cart
Parameters
$iProductCategoryId
mixed
Return
bool
bool isProductInCart($iProductId)
Returns whether a product has been added to the cart
Parameters
$iProductId
mixed
Return
bool
void orderProduct($iProductId, $iQuantity, $arrOptions, $iContactId)
Adds a product to the cart with quantity $iQuantity

If the product already exists in the cart, the quantity is increased by $iQuantity

TODO: deprecate
Parameters
$iProductId
mixed
$iQuantity
mixed
$arrOptions
mixed
$iContactId
mixed
void removeAllItems()
Removes all the items from the cart.
void removeInvalidItems()
Removes all items in the cart that do not have quantity
void removeProduct($iProductId)
Removes all of a particular product from the cart
Parameters
$iProductId
mixed
void removeRow($iCartRowId)
Removes a product
Parameters
$iCartRowId
mixed
void renderPriceExtras()
Renders any extra pricing information such as discounts or payment method hooks
void renderShipping()
void setComments($strComments)
Sets any comments the customer may have on their order
Parameters
$strComments
mixed
void setContactId($iContactId)
Sets the context of the contact who owns the cart

Note: Setting this value only persists for the length of the current request
Parameters
$iContactId
mixed
void setContactShouldInvoiceCompany($bContactShouldInvoiceCompany)
When set to true, the invoice will be created on the contact's company on cart completion
Parameters
$bContactShouldInvoiceCompany
mixed
void setShipping($arrShipping)
Sets the shipping values
Parameters
$arrShipping
mixed
void setShippingColumn($strKey, $strValue)
Parameters
$strKey
mixed
$strValue
mixed
void setShippingMethodId($iMethodId)
Parameters
$iMethodId
mixed
void updateRow($iCartRowId, $iQuantity, $arrOptions, $iContactId, $arrOrderData)
Updates a row in the cart to have a different quantity / options

If the product already exists in the cart, the quantity is set to $iQuantity
Parameters
$iCartRowId
mixed
$iQuantity
mixed
$arrOptions
mixed
$iContactId
mixed
$arrOrderData
mixed

Database Fields

The following fields are used when retrieving and saving entities.