\CartCore

Summary

Methods
Properties
Constants
__construct()
setTaxCalculationMethod()
add()
update()
updateAddressId()
delete()
getTaxesAverageUsed()
getDiscounts()
getCartRules()
getOrderedCartRulesIds()
getDiscountsCustomer()
getLastProduct()
getProducts()
cacheSomeAttributesLists()
nbProducts()
getNbProducts()
addDiscount()
addCartRule()
containsProduct()
updateQty()
_addCustomization()
orderExists()
deleteDiscount()
removeCartRule()
deleteProduct()
getTotalCart()
getOrderTotalUsingTaxCalculationMethod()
getOrderTotal()
getGiftWrappingPrice()
getNbOfPackages()
getPackageList()
getPackageIdWarehouse()
getDeliveryOptionList()
sortDeliveryOptionList()
carrierIsSelected()
simulateCarriersOutput()
simulateCarrierSelectedOutput()
intifier()
desintifier()
isMultiAddressDelivery()
getAddressCollection()
setDeliveryOption()
getDeliveryOption()
getTotalShippingCost()
getCarrierCost()
getOrderShippingCost()
getPackageShippingCost()
getTotalWeight()
checkDiscountValidity()
getSummaryDetails()
checkQuantities()
checkProductsAccess()
lastNoneOrderedCart()
isVirtualCart()
getCartByOrderId()
getCartIdByOrderId()
addTextFieldToProduct()
addPictureToProduct()
deletePictureToProduct()
deleteCustomizationToProduct()
getProductCustomization()
getCustomerCarts()
replaceZeroByShopName()
duplicate()
getWsCartRows()
setWsCartRows()
setProductAddressDelivery()
duplicateProduct()
setNoMultishipping()
autosetProductAddress()
deleteAssociations()
isGuestCartByCartId()
isCarrierInRange()
isAllProductsInStock()
addExtraCarriers()
getDeliveryAddressesWithoutCarriers()
$id
$id_shop_group
$id_shop
$id_address_delivery
$id_address_invoice
$id_currency
$id_customer
$id_guest
$id_lang
$recyclable
$gift
$gift_message
$mobile_theme
$date_add
$secure_key
$id_carrier
$date_upd
$checkedTos
$pictures
$textFields
$delivery_option
$allow_seperated_package
$definition
ONLY_PRODUCTS
ONLY_DISCOUNTS
BOTH
BOTH_WITHOUT_SHIPPING
ONLY_SHIPPING
ONLY_WRAPPING
ONLY_PRODUCTS_WITHOUT_SHIPPING
ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING
_updateCustomizationQuantity()
_deleteCustomization()
getIdCarrierFromDeliveryOption()
$_nbProducts
$_isVirtualCart
$_products
$_totalWeight
$_taxCalculationMethod
$_carriers
$_taxes_rate
$_attributesLists
$_customer
$webserviceParameters
N/A
No private methods found
No private properties found
N/A

Constants

ONLY_PRODUCTS

ONLY_PRODUCTS

ONLY_DISCOUNTS

ONLY_DISCOUNTS

BOTH

BOTH

BOTH_WITHOUT_SHIPPING

BOTH_WITHOUT_SHIPPING

ONLY_SHIPPING

ONLY_SHIPPING

ONLY_WRAPPING

ONLY_WRAPPING

ONLY_PRODUCTS_WITHOUT_SHIPPING

ONLY_PRODUCTS_WITHOUT_SHIPPING

ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING

ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING

Properties

$id

$id : 

Type

$id_shop_group

$id_shop_group : 

Type

$id_shop

$id_shop : 

Type

$id_address_delivery

$id_address_delivery : integer

Type

integer — Customer delivery address ID

$id_address_invoice

$id_address_invoice : integer

Type

integer — Customer invoicing address ID

$id_currency

$id_currency : integer

Type

integer — Customer currency ID

$id_customer

$id_customer : integer

Type

integer — Customer ID

$id_guest

$id_guest : integer

Type

integer — Guest ID

$id_lang

$id_lang : integer

Type

integer — Language ID

$recyclable

$recyclable : boolean

Type

boolean — True if the customer wants a recycled package

$gift

$gift : boolean

Type

boolean — True if the customer wants a gift wrapping

$gift_message

$gift_message : string

Type

string — Gift message if specified

$mobile_theme

$mobile_theme : boolean

Type

boolean — Mobile Theme

$date_add

$date_add : string

Type

string — Object creation date

$secure_key

$secure_key : string

Type

string — secure_key

$id_carrier

$id_carrier : integer

Type

integer — Carrier ID

$date_upd

$date_upd : string

Type

string — Object last modification date

$checkedTos

$checkedTos : 

Type

$pictures

$pictures : 

Type

$textFields

$textFields : 

Type

$delivery_option

$delivery_option : 

Type

$allow_seperated_package

$allow_seperated_package : boolean

Type

boolean — Allow to seperate order in multiple package in order to recieve as soon as possible the available products

$definition

$definition : 

Type

$_nbProducts

$_nbProducts : 

Type

$_isVirtualCart

$_isVirtualCart : 

Type

$_products

$_products : 

Type

$_totalWeight

$_totalWeight : 

Type

$_taxCalculationMethod

$_taxCalculationMethod : 

Type

$_carriers

$_carriers : 

Type

$_taxes_rate

$_taxes_rate : 

Type

$_attributesLists

$_attributesLists : 

Type

$_customer

$_customer : 

Type

$webserviceParameters

$webserviceParameters : 

Type

Methods

__construct()

__construct(  $id = null,   $id_lang = null) 

Parameters

$id
$id_lang

setTaxCalculationMethod()

setTaxCalculationMethod() 

add()

add(  $autodate = true,   $null_values = false) 

Parameters

$autodate
$null_values

update()

update(  $null_values = false) 

Parameters

$null_values

updateAddressId()

updateAddressId(integer  $id_address, integer  $id_address_new) 

Update the address id of the cart

Parameters

integer $id_address

Current address id to change

integer $id_address_new

New address id

delete()

delete() 

getTaxesAverageUsed()

getTaxesAverageUsed(  $id_cart) 

Parameters

$id_cart

getDiscounts()

getDiscounts(  $lite = false,   $refresh = false) 

Parameters

$lite
$refresh

getCartRules()

getCartRules(  $filter = \CartRule::FILTER_ACTION_ALL) 

Parameters

$filter

getOrderedCartRulesIds()

getOrderedCartRulesIds(  $filter = \CartRule::FILTER_ACTION_ALL) : array

Return the cart rules Ids on the cart.

Parameters

$filter

Throws

\PrestaShopDatabaseException

Returns

array

getDiscountsCustomer()

getDiscountsCustomer(  $id_cart_rule) 

Parameters

$id_cart_rule

getLastProduct()

getLastProduct() 

getProducts()

getProducts(  $refresh = false,   $id_product = false,   $id_country = null) 

Return cart products

Parameters

$refresh
$id_product
$id_country

cacheSomeAttributesLists()

cacheSomeAttributesLists(  $ipa_list,   $id_lang) 

Parameters

$ipa_list
$id_lang

nbProducts()

nbProducts() 

Return cart products quantity

getNbProducts()

getNbProducts(  $id) 

Parameters

$id

addDiscount()

addDiscount(  $id_cart_rule) 

Parameters

$id_cart_rule

addCartRule()

addCartRule(  $id_cart_rule) 

Parameters

$id_cart_rule

containsProduct()

containsProduct(  $id_product,   $id_product_attribute,   $id_customization,   $id_address_delivery) 

Parameters

$id_product
$id_product_attribute
$id_customization
$id_address_delivery

updateQty()

updateQty(integer  $quantity, integer  $id_product, integer  $id_product_attribute = null,   $id_customization = false, string  $operator = 'up',   $id_address_delivery, \Shop  $shop = null,   $auto_add_cart_rule = true) 

Update product quantity

Parameters

integer $quantity

Quantity to add (or substract)

integer $id_product

Product ID

integer $id_product_attribute

Attribute ID if needed

$id_customization
string $operator

Indicate if quantity must be increased or decreased

$id_address_delivery
\Shop $shop
$auto_add_cart_rule

_addCustomization()

_addCustomization(integer  $id_product, integer  $id_product_attribute, integer  $index, integer  $type, string  $field, integer  $quantity) : boolean

Add customization item to database

Parameters

integer $id_product
integer $id_product_attribute
integer $index
integer $type
string $field
integer $quantity

Returns

boolean —

success

orderExists()

orderExists() : boolean

Check if order has already been placed

Returns

boolean —

result

deleteDiscount()

deleteDiscount(  $id_cart_rule) 

Parameters

$id_cart_rule

removeCartRule()

removeCartRule(  $id_cart_rule) 

Parameters

$id_cart_rule

deleteProduct()

deleteProduct(integer  $id_product, integer  $id_product_attribute = null, integer  $id_customization = null,   $id_address_delivery) : boolean

Delete a product from the cart

Parameters

integer $id_product

Product ID

integer $id_product_attribute

Attribute ID if needed

integer $id_customization

Customization id

$id_address_delivery

Returns

boolean —

result

getTotalCart()

getTotalCart(  $id_cart,   $use_tax_display = false,   $type = \Cart::BOTH) 

Parameters

$id_cart
$use_tax_display
$type

getOrderTotalUsingTaxCalculationMethod()

getOrderTotalUsingTaxCalculationMethod(  $id_cart) 

Parameters

$id_cart

getOrderTotal()

getOrderTotal(  $with_taxes = true, integer  $type = \Cart::BOTH,   $products = null,   $id_carrier = null, boolean  $use_cache = true) : float

This function returns the total cart amount

Possible values for $type: Cart::ONLY_PRODUCTS Cart::ONLY_DISCOUNTS Cart::BOTH Cart::BOTH_WITHOUT_SHIPPING Cart::ONLY_SHIPPING Cart::ONLY_WRAPPING Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING

Parameters

$with_taxes
integer $type

Total type

$products
$id_carrier
boolean $use_cache

Allow using cache of the method CartRule::getContextualValue

Returns

float —

Order total

getGiftWrappingPrice()

getGiftWrappingPrice(boolean  $with_taxes = true,   $id_address = null) : float

Get the gift wrapping price

Parameters

boolean $with_taxes

With or without taxes

$id_address

Returns

float —

wrapping price

getNbOfPackages()

getNbOfPackages() : integer

Get the number of packages

Returns

integer —

number of packages

getPackageList()

getPackageList(  $flush = false) : array

Get products grouped by package and by addresses to be sent individualy (one package = one shipping cost).

Parameters

$flush

Returns

array —

array( 0 => array( // First address 0 => array( // First package 'product_list' => array(...), 'carrier_list' => array(...), 'id_warehouse' => array(...), ), ), );

getPackageIdWarehouse()

getPackageIdWarehouse(  $package,   $id_carrier = null) 

Parameters

$package
$id_carrier

getDeliveryOptionList()

getDeliveryOptionList(\Country  $default_country = null, boolean  $flush = false) : array

Get all deliveries options available for the current cart

Parameters

\Country $default_country
boolean $flush

Force flushing cache

Returns

array —

array( 0 => array( // First address '12,' => array( // First delivery option available for this address carrier_list => array( 12 => array( // First carrier for this option 'instance' => Carrier Object, 'logo' => , 'price_with_tax' => 12.4, 'price_without_tax' => 12.4, 'package_list' => array( 1, 3, ), ), ), is_best_grade => true, // Does this option have the biggest grade (quick shipping) for this shipping address is_best_price => true, // Does this option have the lower price for this shipping address unique_carrier => true, // Does this option use a unique carrier total_price_with_tax => 12.5, total_price_without_tax => 12.5, position => 5, // Average of the carrier position ), ), ); If there are no carriers available for an address, return an empty array

sortDeliveryOptionList()

sortDeliveryOptionList(  $option1,   $option2) : integer

Sort list of option delivery by parameters define in the BO

Parameters

$option1
$option2

Returns

integer —

-1 if $option 1 must be placed before and 1 if the $option1 must be placed after the $option2

carrierIsSelected()

carrierIsSelected(  $id_carrier,   $id_address) 

Parameters

$id_carrier
$id_address

simulateCarriersOutput()

simulateCarriersOutput(\Country  $default_country = null, boolean  $flush = false) 

Get all deliveries options available for the current cart formated like Carriers::getCarriersForOrder This method was wrote for retrocompatibility with 1.4 theme New theme need to use Cart::getDeliveryOptionList() to generate carriers option in the checkout process

Parameters

\Country $default_country
boolean $flush

Force flushing cache

simulateCarrierSelectedOutput()

simulateCarrierSelectedOutput(  $use_cache = true) 

Parameters

$use_cache

intifier()

intifier(  $string,   $delimiter = ',') : integer

Translate a string option_delivery identifier ('24,3,') in a int (3240002000)

The option_delivery identifier is a list of integers separated by a ','. This method replace the delimiter by a sequence of '0'. The size of this sequence is fixed by the first digit of the return

Parameters

$string
$delimiter

Returns

integer

desintifier()

desintifier(  $int,   $delimiter = ',') 

Translate a int option_delivery identifier (3240002000) in a string ('24,3,')

Parameters

$int
$delimiter

isMultiAddressDelivery()

isMultiAddressDelivery() : boolean

Does the cart use multiple address

Returns

boolean

getAddressCollection()

getAddressCollection() 

Get all delivery addresses object for the current cart

setDeliveryOption()

setDeliveryOption(  $delivery_option = null) 

Set the delivery option and id_carrier, if there is only one carrier

Parameters

$delivery_option

getDeliveryOption()

getDeliveryOption(  $default_country = null,   $dontAutoSelectOptions = false,   $use_cache = true) : array

Get the delivery option seleted, or if no delivery option was selected, the cheapest option for each address

Parameters

$default_country
$dontAutoSelectOptions
$use_cache

Returns

array —

delivery option

getTotalShippingCost()

getTotalShippingCost(array  $delivery_option = null, \booleal  $use_tax = true, \Country  $default_country = null) : float

Return shipping total for the cart

Parameters

array $delivery_option

Array of the delivery option for each address

\booleal $use_tax
\Country $default_country

Returns

float —

Shipping total

getCarrierCost()

getCarrierCost(integer  $id_carrier, \booleal  $useTax = true, \Country  $default_country = null, array  $delivery_option = null) : float

Return shipping total of a specific carriers for the cart

Parameters

integer $id_carrier
\booleal $useTax
\Country $default_country
array $delivery_option

Array of the delivery option for each address

Returns

float —

Shipping total

getOrderShippingCost()

getOrderShippingCost(  $id_carrier = null,   $use_tax = true, \Country  $default_country = null,   $product_list = null) 

Parameters

$id_carrier
$use_tax
\Country $default_country
$product_list

getPackageShippingCost()

getPackageShippingCost(integer  $id_carrier = null, \booleal  $use_tax = true, \Country  $default_country = null, array  $product_list = null,   $id_zone = null) : float

Return package shipping cost

Parameters

integer $id_carrier

Carrier ID (default : current carrier)

\booleal $use_tax
\Country $default_country
array $product_list

List of product concerned by the shipping. If null, all the product of the cart are used to calculate the shipping cost

$id_zone

Returns

float —

Shipping total

getTotalWeight()

getTotalWeight(  $products = null) : float

Return cart weight

Parameters

$products

Returns

float —

Cart weight

checkDiscountValidity()

checkDiscountValidity(  $obj,   $discounts,   $order_total,   $products,   $check_cart_discount = false) 

Parameters

$obj
$discounts
$order_total
$products
$check_cart_discount

getSummaryDetails()

getSummaryDetails(  $id_lang = null,   $refresh = false) : array

Return useful informations for cart

Parameters

$id_lang
$refresh

Returns

array —

Cart details

checkQuantities()

checkQuantities(  $return_product = false) 

Parameters

$return_product

checkProductsAccess()

checkProductsAccess() 

lastNoneOrderedCart()

lastNoneOrderedCart(  $id_customer) 

Parameters

$id_customer

isVirtualCart()

isVirtualCart(  $strict = false) : boolean

Check if cart contains only virtual products

Parameters

$strict

Returns

boolean —

true if is a virtual cart or false

getCartByOrderId()

getCartByOrderId(integer  $id_order) : \Cart|boolean

Build cart object from provided id_order

Parameters

integer $id_order

Returns

\Cart|boolean

getCartIdByOrderId()

getCartIdByOrderId(  $id_order) 

Parameters

$id_order

addTextFieldToProduct()

addTextFieldToProduct(  $id_product,   $index,   $type,   $text_value) : boolean

Add customer's text

Parameters

$id_product
$index
$type
$text_value

Returns

boolean —

Always true

addPictureToProduct()

addPictureToProduct(  $id_product,   $index,   $type,   $file) : boolean

Add customer's pictures

Parameters

$id_product
$index
$type
$file

Returns

boolean —

Always true

deletePictureToProduct()

deletePictureToProduct(  $id_product,   $index) 

Parameters

$id_product
$index

deleteCustomizationToProduct()

deleteCustomizationToProduct(integer  $id_product, integer  $index) : boolean

Remove a customer's customization

Parameters

integer $id_product
integer $index

Returns

boolean

getProductCustomization()

getProductCustomization(integer  $id_product, integer  $type = null, boolean  $not_in_cart = false) : array

Return custom pictures in this cart for a specified product

Parameters

integer $id_product
integer $type

only return customization of this type

boolean $not_in_cart

only return customizations that are not in cart already

Returns

array —

result rows

getCustomerCarts()

getCustomerCarts(  $id_customer,   $with_order = true) 

Parameters

$id_customer
$with_order

replaceZeroByShopName()

replaceZeroByShopName(  $echo,   $tr) 

Parameters

$echo
$tr

duplicate()

duplicate() 

getWsCartRows()

getWsCartRows() 

setWsCartRows()

setWsCartRows(  $values) 

Parameters

$values

setProductAddressDelivery()

setProductAddressDelivery(  $id_product,   $id_product_attribute,   $old_id_address_delivery,   $new_id_address_delivery) 

Parameters

$id_product
$id_product_attribute
$old_id_address_delivery
$new_id_address_delivery

duplicateProduct()

duplicateProduct(  $id_product,   $id_product_attribute,   $id_address_delivery,   $new_id_address_delivery,   $quantity = 1,   $keep_quantity = false) 

Parameters

$id_product
$id_product_attribute
$id_address_delivery
$new_id_address_delivery
$quantity
$keep_quantity

setNoMultishipping()

setNoMultishipping() 

Update products cart address delivery with the address delivery of the cart

autosetProductAddress()

autosetProductAddress() 

Set an address to all products on the cart without address delivery

deleteAssociations()

deleteAssociations() 

isGuestCartByCartId()

isGuestCartByCartId(integer  $id_cart) : boolean

isGuestCartByCartId

Parameters

integer $id_cart

Returns

boolean —

true if cart has been made by a guest customer

isCarrierInRange()

isCarrierInRange(  $id_carrier,   $id_zone) 

isCarrierInRange

Check if the specified carrier is in range

Parameters

$id_carrier
$id_zone

isAllProductsInStock()

isAllProductsInStock(boolean  $ignore_virtual = false, boolean  $exclusive = false) : boolean

Parameters

boolean $ignore_virtual

Ignore virtual product

boolean $exclusive

If true, the validation is exclusive : it must be present product in stock and out of stock

Returns

boolean —

false is some products from the cart are out of stock

addExtraCarriers()

addExtraCarriers(array  $array) 

Execute hook displayCarrierList (extraCarrier) and merge theme to the $array

Parameters

array $array

getDeliveryAddressesWithoutCarriers()

getDeliveryAddressesWithoutCarriers(boolean  $return_collection = false) : array

Get all the ids of the delivery addresses without carriers

Parameters

boolean $return_collection

Return a collection

Returns

array —

Array of address id or of address object

_updateCustomizationQuantity()

_updateCustomizationQuantity(  $quantity,   $id_customization,   $id_product,   $id_product_attribute,   $id_address_delivery,   $operator = 'up') 

Parameters

$quantity
$id_customization
$id_product
$id_product_attribute
$id_address_delivery
$operator

_deleteCustomization()

_deleteCustomization(integer  $id_customization,   $id_product,   $id_product_attribute,   $id_address_delivery) : boolean

Delete a customization from the cart. If customization is a Picture, then the image is also deleted

Parameters

integer $id_customization
$id_product
$id_product_attribute
$id_address_delivery

Returns

boolean —

result

getIdCarrierFromDeliveryOption()

getIdCarrierFromDeliveryOption(  $delivery_option) 

Parameters

$delivery_option