Shopping Cart of the Current User

Access and modify the shopping cart of the current visitor.

Class Methods

The following methods can be invoked on instances of this class.

initialize()

Initialize

isCustomItem(array arrCartItem)

Determines if a cart item is custom or if corresponds to a product

isProductInCart(int iProductId)

Returns whether or not a product has been added to the cart

isProductCategoryInCart(int iProductCategoryId)

Returns whether or not a product has been added to the cart

cookieLoad()

Loads the cart from a cookie

cookieSave()

Writes the cookie

cookieDelete()

Deletes the cart cookie

customCartAlgorithm()

dbSave()

Writes the shopping cart to the database
You should not call this function outside of this class. It is only called by PayPal during checkout as it needs to save, then redirect during payment

dbLoad()

Loads a cart from the database using the cart id
This method does not write out a cookie or back to the db

dbDelete()

Deletes the cart from the database

applyCurrencyBasedRounding(float fAmount)

Rounds a value to the precision of the current currency

create()

Forces the creation of a cart and returns its id

setCartId(int iCartId)

Sets the id for the cart

getCartId()

Returns the id for the cart

setIsAdmin(bool bIsAdmin)

Sets the is_admin flag, which indicates weither the current cart is used from an admin or public page.
This should be set to true on any admin page using the cart.

getIsAdmin()

Determines if the the current cart is used from an admin or public page.
This should be set to true on any admin page using the cart.

setIsLoadedFromSale(bool bIsLoadedFromSale)

Sets whether the current cart is loaded from a sale or not

getIsLoadedFromSale()

Returns whether the current cart is loaded from a sale or not

setContactId(int iContactId)

Sets the context of the contact who owns the cart
Note: Setting this value only persists for the length of the current request

getContactId()

Returns the id of the contact who owns the cart

getContact()

Returns the id of the contact who owns the cart

setContactShouldInvoiceCompany(bool bContactShouldInvoiceCompany)

When set to true, the invoice will be created on the contact's company on cart completion

getContactShouldInvoiceCompany()

Returns whether to invoice the contact's company on cart completion

getContactShouldInvoiceCompanyContact()

When invoicing a company, this function returns the company

getOrderMinimumAmount()

Retrieves the order minimum value as configured in the config item

setCurrencyId(string strCurrencyId)

Overrides the currency detection and explicitly sets a currency on the cart

getCurrencyId()

Returns the current currency id

getCountry()

Returns the country of the contact uses this cart

getCountryState()

Returns the country of the contact uses this cart

getCurrentTax()

Returns the current tax which has to be applied on this cart

getCurrentTaxLabel()

Returns the current tax label

getCurrentTaxRate()

Returns the current tax label

getProductOrderedQuantity(mixed iProductId, int iContactId)

Retrieves the ordered quantity for a specific product for a specific contact

orderProduct(mixed iProductId, mixed iQuantity, array arrOptions, mixed 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

addProduct(mixed arrOptions)

Adds a product to the shopping cart

removeProduct(int iProductId)

Removes all of a particular product from the cart

getRow(mixed iCartRowId)

getRowDetailed(mixed iCartRowId)

getRowProductId(mixed iCartRowId)

getAll()

Returns the shopping cart as an array
array(array('product_id' => $iProductId, 'product_quantity' => $iQuantity), ...)

getAllDetailed()

Returns the shopping cart as an array with the details of the products, calculated tax
and shipping

getCount()

Returns the number of item rows in the shopping cart

getCountProducts()

Returns the total quantity of products in the shopping cart

hasProduct(int iProductId)

Returns whether or not a product is in the cart

updateRow(mixed iCartRowId, mixed iQuantity, mixed arrOptions, mixed iContactId, array|bool 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

removeRow(int iCartRowId)

Removes a product

removeInvalidItems()

Removes all items in the cart that do not have quantity

removeAllItems()

Removes all the items from the cart.

getTotal(mixed bIncludeShipping, bool bIncludeDiscounts)

Returns the total dollar value of the items in the shopping cart

getTotalProducts()

Returns the dollar value total of just the products in the cart

getTotalProductsNoDiscounts()

Returns the total of products without any product discount being applied

getTotalTax()

Returns the dollar value total tax for the items in the cart

getTotalTaxLabel()

Returns the label for the tax rate - eg: 'GST'

getTotalTaxPercent()

Returns the tax rate - eg: '10%'

getTotalDiscounts()

Returns the total amount of discount for the cart

getTotalShipping()

Returns the dollar value total of the shipping

getTotalWeight()

Returns the total weight for the cart.

calculateDimensionsMM(mixed iCubicBreak, float fWeightBreak)

Returns the cubic size of a sale

setShippingMethodId(mixed iMethodId)

getShippingMethodId()

getShippingMethodClass()

getShippingMethodConfiguration()

Returns the configuration options for the shipping method

setShipping(array arrEntity)

Sets the shipping values

setShippingColumn(mixed strKey, mixed strValue)

getShipping()

Returns the current shipping details

getShippingColumn(string strColumn)

Returns a column of the orders shipping details

getShippingHasPassedStep()

getIsShippingRequired()

Returns whether shipping is required for the products currently in the cart

getShippingErrors()

Returns an array of any errors encountered when calculating shipping

renderShipping()

getIsGuestCheckoutDisabled()

Returns whether or not the 'guest checkout' option is disabled for cart.
This is derived from the products in the cart.

reload()

Reloads the cart items

setPaymentMethodId(int iPaymentMethodId)

Sets the payment method id used when the order is processed

setUseAvailableAdjustments(bool bUseAdjustments)

Sets the flag allowing to use or not adjustments
available to the contact during complete()

getUseAvailableAdjustments()

Determines if adjustments available to the contact
should be used during complete()

getPaymentMethodId(bool bUseDefault)

Returns the payment method id used when the order is processed

getPaymentMethod()

getPaymentMethodClass()

Returns the payment method used when the order is processed

setDiscountIds(array arrDiscountIds)

Sets an array of discount ids for this order

getDiscountIds()

Returns an array of discount ids for this order

getDiscounts()

Returns an array of discounts for this order

hasDiscounts()

Returns whether the cart has discounts

hasDiscountId(int iDiscountId)

Returns whether the cart has a particular discount applied

hasDiscountFreeShipping()

Returns whether the cart has free shipping

setComments(string strComments)

Sets any comments the customer may have on their order

getComments()

Returns any comments the customer may have on their order

convertPostedProductOptionsToAssoc(mixed iProductId, mixed arrOrderOptionsPost)

getIsSubmittable()

Returns whether the cart is submittable or not

checkRequiredContactFields()

Checks to see if the logged in contact has all of the required fields

checkContactFullnameOrCompanyFields()

Checks if the fullname or the company of the contact has been filled in

getStep(mixed bHasProducts, mixed bContact, mixed bContactUpdate, bool bShipping)

Returns the page of the recommended step in the ordering process

clear()

Clears the cart

clearItems()

Clears the cart

complete(array arrPaymentEntity)

Process and complete the current cart.

componentIsInstalled()

Determines if a specific component is installed

componentGetEntityType(mixed arrEntity)

Returns the type of entity handled by the component

componentGetEntityIcon()

Retrieves the default icon path for the component entities

install()

Installs the component

uninstall()

Uninstalls the component

eventGetHandlers()

Returns a set of event handlers for this component

eventTrigger(mixed strEvent, array arrEventParams)

Triggers a component event

securityOperationsGetAll()

Returns a set of security operations for this component

configGetAll(array arrProperties)

Retrieves all config items for the component

configGetAllValues(array arrProperties)

Retrieves all config items for the component in a item_id => item_value fashion

configGetValue(string strConfigId)

Retrieves the value of a config item for the current component

configSaveValue(mixed strConfigId, mixed strValue, string strReason)

Saves the value of a config item for the current component

uiGetActions(mixed bInList, bool bInEdit)

Returns an array of user interface actions for the component

__call(mixed strName, array arrArguments)

Magic function to trap calls to undefined functions and throw an exception rather than
a fatal error.

__callStatic(mixed strName, array arrArguments)

Magic function to trap static calls to undefined functions and throw an exception rather
than a fatal error.

classGetFolder()

Returns the folder where the class exists

__set_state(mixed arrValues)

classGetFolderResources()

Returns the folder where the class's resources exist

classGetSrcFile()

Returns the folder where the class exists

classGetSrcHash()

Returns the folder where the class exists

classGetReflection()

Returns the reflection data for the current class

classGetReflectionAnnotation(string strField)

Returns a specific class annotation for the current class