Skip to content

Latest commit

 

History

History
2936 lines (1475 loc) · 64.2 KB

class.CartCore.md

File metadata and controls

2936 lines (1475 loc) · 64.2 KB

Class CartCore

Contents

Constants

Properties

Methods

Constants

BOTH

const BOTH = 3

BOTH_WITHOUT_SHIPPING

const BOTH_WITHOUT_SHIPPING = 4

ONLY_DISCOUNTS

const ONLY_DISCOUNTS = 2

ONLY_PRODUCTS

const ONLY_PRODUCTS = 1

ONLY_PRODUCTS_WITHOUT_SHIPPING

const ONLY_PRODUCTS_WITHOUT_SHIPPING = 7

ONLY_SHIPPING

const ONLY_SHIPPING = 5

ONLY_WRAPPING

const ONLY_WRAPPING = 6

Properties

$_attributesLists

protected mixed $_attributesLists = array()

$_carriers

protected mixed $_carriers = null

$_isVirtualCart

protected mixed $_isVirtualCart = array()

$_nbProducts

protected mixed $_nbProducts = array()

$_products

protected mixed $_products = null

$_taxCalculationMethod

protected mixed $_taxCalculationMethod = PS_TAX_EXC

$_taxes_rate

protected mixed $_taxes_rate = null

$_totalWeight

protected mixed $_totalWeight = array()

$allow_seperated_package

public boolean $allow_seperated_package = false

$checkedTos

public mixed $checkedTos = false

$date_add

public string $date_add

$date_upd

public string $date_upd

$definition

public mixed $definition = array('table' => 'cart', 'primary' => 'id_cart', 'fields' => array('id_group_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_address_delivery' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_address_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_carrier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_guest' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'recyclable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'gift_message' => array('type' => self::TYPE_STRING, 'validate' => 'isMessage'), 'delivery_option' => array('type' => self::TYPE_STRING), 'secure_key' => array('type' => self::TYPE_STRING, 'size' => 32), 'allow_seperated_package' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat')))

$delivery_option

public mixed $delivery_option

$gift

public boolean $gift

$gift_message

public string $gift_message

$id

public mixed $id

$id_address_delivery

public integer $id_address_delivery

$id_address_invoice

public integer $id_address_invoice

$id_carrier

public mixed $id_carrier

$id_currency

public integer $id_currency

$id_customer

public integer $id_customer

$id_group_shop

public mixed $id_group_shop

$id_guest

public integer $id_guest

$id_lang

public integer $id_lang

$id_shop

public mixed $id_shop

$pictures

public mixed $pictures

$recyclable

public boolean $recyclable = 1

$secure_key

public string $secure_key

$textFields

public mixed $textFields

$webserviceParameters

protected mixed $webserviceParameters = array('fields' => array('id_address_delivery' => array('xlink_resource' => 'addresses'), 'id_address_invoice' => array('xlink_resource' => 'addresses'), 'id_currency' => array('xlink_resource' => 'currencies'), 'id_customer' => array('xlink_resource' => 'customers'), 'id_guest' => array('xlink_resource' => 'guests'), 'id_lang' => array('xlink_resource' => 'languages')), 'associations' => array('cart_rows' => array('resource' => 'cart_row', 'virtual_entity' => true, 'fields' => array('id_product' => array('required' => true, 'xlink_resource' => 'products'), 'id_product_attribute' => array('required' => true, 'xlink_resource' => 'combinations'), 'quantity' => array('required' => true)))))

$def

protected array $def

$fieldsRequired

protected mixed $fieldsRequired = array()

$fieldsRequiredDatabase

protected mixed $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected mixed $fieldsRequiredLang = array()

$fieldsSize

protected mixed $fieldsSize = array()

$fieldsSizeLang

protected mixed $fieldsSizeLang = array()

$fieldsValidate

protected mixed $fieldsValidate = array()

$fieldsValidateLang

protected mixed $fieldsValidateLang = array()

$identifier

protected mixed $identifier

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$table

protected mixed $table

$tables

protected mixed $tables = array()

Methods

__construct

mixed CartCore::__construct($id, $id_lang)

Arguments

  • $id mixed
  • $id_lang mixed

_addCustomization

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

Add customization item to database

Arguments

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

_deleteCustomization

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

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

Arguments

  • $id_customization integer
  • $id_product mixed
  • $id_product_attribute mixed
  • $id_address_delivery mixed

_updateCustomizationQuantity

mixed CartCore::_updateCustomizationQuantity($quantity, $id_customization, $id_product, $id_product_attribute, $id_address_delivery, $operator)

Arguments

  • $quantity mixed
  • $id_customization mixed
  • $id_product mixed
  • $id_product_attribute mixed
  • $id_address_delivery mixed
  • $operator mixed

add

mixed CartCore::add($autodate, $null_values)

Arguments

  • $autodate mixed
  • $null_values mixed

addCartRule

mixed CartCore::addCartRule($id_cart_rule)

Arguments

  • $id_cart_rule mixed

addDiscount

mixed CartCore::addDiscount($id_cart_rule)

Arguments

  • $id_cart_rule mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addPictureToProduct

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

Add customer's pictures

Arguments

  • $id_product mixed
  • $index mixed
  • $type mixed
  • $file mixed

addTextFieldToProduct

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

Add customer's text

Arguments

  • $id_product mixed
  • $index mixed
  • $type mixed
  • $text_value mixed

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops, string $type)

This function associate an item to its context

Arguments

  • $id_shops integer|array
  • $type string

autosetProductAddress

mixed CartCore::autosetProductAddress()

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

cacheSomeAttributesLists

mixed CartCore::cacheSomeAttributesLists($ipa_list, $id_lang)

Arguments

  • $ipa_list mixed
  • $id_lang mixed

checkDiscountValidity

mixed CartCore::checkDiscountValidity($obj, $discounts, $order_total, $products, $check_cart_discount)

Arguments

  • $obj mixed
  • $discounts mixed
  • $order_total mixed
  • $products mixed
  • $check_cart_discount mixed

checkQuantities

mixed CartCore::checkQuantities()

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

containsProduct

mixed CartCore::containsProduct($id_product, $id_product_attribute, $id_customization, $id_address_delivery)

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $id_customization mixed
  • $id_address_delivery mixed

delete

mixed CartCore::delete()

deleteAssociations

mixed CartCore::deleteAssociations()

deleteCustomizationToProduct

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

Remove a customer's customization

Arguments

  • $id_product integer
  • $index integer

deleteDiscount

mixed CartCore::deleteDiscount($id_cart_rule)

Arguments

  • $id_cart_rule mixed

deleteImage

boolean ObjectModelCore::deleteImage()

Delete images associated with the object

deleteProduct

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

Delete a product from the cart

Arguments

  • $id_product integer - Product ID
  • $id_product_attribute integer - Attribute ID if needed
  • $id_customization integer - Customization id
  • $id_address_delivery mixed

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

desintifier

mixed CartCore::desintifier($int, $delimiter)

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

Arguments

  • $int mixed
  • $delimiter mixed

displayFieldName

mixed ObjectModelCore::displayFieldName($field, $className, $htmlentities, \Context $context)

Arguments

  • $field mixed
  • $className mixed
  • $htmlentities mixed
  • $context Context

duplicate

mixed CartCore::duplicate()

duplicateProduct

mixed CartCore::duplicateProduct($id_product, $id_product_attribute, $id_address_delivery, $new_id_address_delivery, $quantity, $keep_quantity)

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $id_address_delivery mixed
  • $new_id_address_delivery mixed
  • $quantity mixed
  • $keep_quantity mixed

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

existsInDatabase

boolean ObjectModelCore::existsInDatabase(integer $id_entity, string $table)

Specify if an ObjectModel is already in database

Arguments

  • $id_entity integer
  • $table string

formatFields

array ObjectModelCore::formatFields(integer $id_lang)

Arguments

  • $id_lang integer - If this parameter is given, only take lang fields

formatValue

mixed ObjectModelCore::formatValue(mixed $value, integer $type, $with_quotes)

Format a data

Arguments

  • $value mixed
  • $type integer
  • $with_quotes mixed

getAddressCollection

mixed CartCore::getAddressCollection()

Get all delivery addresses object for the current cart

getCarrierCost

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

Return shipping total of a specific carriers for the cart

Arguments

  • $id_carrier integer
  • $useTax booleal
  • $default_country Country
  • $delivery_option array - Array of the delivery option for each address

getCartByOrderId

\Cart|boolean CartCore::getCartByOrderId(integer $id_order)

Build cart object from provided id_order

Arguments

  • $id_order integer

getCartIdByOrderId

mixed CartCore::getCartIdByOrderId($id_order)

Arguments

  • $id_order mixed

getCartRules

mixed CartCore::getCartRules()

getCustomerCarts

mixed CartCore::getCustomerCarts($id_customer)

Arguments

  • $id_customer mixed

getDefinition

mixed ObjectModelCore::getDefinition($class, $field)

Arguments

  • $class mixed
  • $field mixed

getDeliveryOption

array CartCore::getDeliveryOption($default_country)

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

Arguments

  • $default_country mixed

getDeliveryOptionList

array CartCore::getDeliveryOptionList(\Country $default_country, boolean $flush)

Get all deliveries options available for the current cart

Arguments

  • $default_country Country
  • $flush boolean - Force flushing cache

getDiscounts

mixed CartCore::getDiscounts($lite, $refresh)

Arguments

  • $lite mixed
  • $refresh mixed

getDiscountsCustomer

mixed CartCore::getDiscountsCustomer($id_cart_rule)

Arguments

  • $id_cart_rule mixed

getEntity

mixed ObjectModelCore::getEntity($entity)

Arguments

  • $entity mixed

getFields

array ObjectModelCore::getFields()

Prepare fields for ObjectModel class (add, update) All fields are verified (pSQL, intval.

..)

getFieldsLang

array ObjectModelCore::getFieldsLang()

Prepare multilang fields

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getIdCarrierFromDeliveryOption

mixed CartCore::getIdCarrierFromDeliveryOption($delivery_option)

Arguments

  • $delivery_option mixed

getLastProduct

mixed CartCore::getLastProduct()

getNbProducts

mixed CartCore::getNbProducts($id)

Arguments

  • $id mixed

getOrderShippingCost

float CartCore::getOrderShippingCost(integer $id_carrier, \booleal $use_tax, \Country $default_country, Array $product_list)

Return shipping total This function is dépreciate, use getTotalShippingCost or getPackageShippingCost

Arguments

  • $id_carrier integer - Carrier ID (default : current carrier)
  • $use_tax booleal
  • $default_country Country
  • $product_list Array

getOrderTotal

float CartCore::getOrderTotal($with_taxes, integer $type, $products, $id_carrier)

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

Arguments

  • $with_taxes mixed
  • $type integer - Total type
  • $products mixed
  • $id_carrier mixed

getOrderTotalUsingTaxCalculationMethod

mixed CartCore::getOrderTotalUsingTaxCalculationMethod($id_cart)

Arguments

  • $id_cart mixed

getPackageList

array CartCore::getPackageList($flush)

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

Arguments

  • $flush mixed

getPackageShippingCost

float CartCore::getPackageShippingCost(integer $id_carrier, \booleal $use_tax, \Country $default_country, Array $product_list)

Return package shipping cost

Arguments

  • $id_carrier integer - Carrier ID (default : current carrier)
  • $use_tax booleal
  • $default_country Country
  • $product_list Array

getProductCustomization

array CartCore::getProductCustomization(integer $id_product, integer $type, boolean $not_in_cart)

Return custom pictures in this cart for a specified product

Arguments

  • $id_product integer
  • $type integer - only return customization of this type
  • $not_in_cart boolean - only return customizations that are not in cart already

getProducts

mixed CartCore::getProducts($refresh, $id_product, $id_country)

Return cart products

Arguments

  • $refresh mixed
  • $id_product mixed
  • $id_country mixed

getSummaryDetails

array CartCore::getSummaryDetails($id_lang)

Return useful informations for cart

Arguments

  • $id_lang mixed

getTaxesAverageUsed

mixed CartCore::getTaxesAverageUsed($id_cart)

Arguments

  • $id_cart mixed

getTotalCart

mixed CartCore::getTotalCart($id_cart, $use_tax_display)

Arguments

  • $id_cart mixed
  • $use_tax_display mixed

getTotalShippingCost

float CartCore::getTotalShippingCost(array $delivery_option, \booleal $use_tax, \Country $default_country)

Return shipping total for the cart

Arguments

  • $delivery_option array - Array of the delivery option for each address
  • $use_tax booleal
  • $default_country Country

getTotalWeight

float CartCore::getTotalWeight($products)

Return cart weight

Arguments

  • $products mixed

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fieldsArray)

Arguments

  • $fieldsArray mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $className)

Returns object validation rules (fields validity)

Arguments

  • $className string - Child class name for static use (optional)

getWebserviceObjectList

mixed ObjectModelCore::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit)

Arguments

  • $sql_join mixed
  • $sql_filter mixed
  • $sql_sort mixed
  • $sql_limit mixed

getWebserviceParameters

mixed ObjectModelCore::getWebserviceParameters($wsParamsAttributeName)

Arguments

  • $wsParamsAttributeName mixed

getWsCartRows

mixed CartCore::getWsCartRows()

hydrate

mixed ObjectModelCore::hydrate(array $data, integer $id_lang)

Fill an object with given data. Data must be an array with this syntax: array(objProperty => value, objProperty2 => value, etc.)

Arguments

  • $data array
  • $id_lang integer

hydrateCollection

array ObjectModelCore::hydrateCollection(string $class, array $datas, integer $id_lang)

Fill (hydrate) a list of objects in order to get a collection of these objects

Arguments

  • $class string - Class of objects to hydrate
  • $datas array - List of data (multi-dimensional array)
  • $id_lang integer

intifier

integer CartCore::intifier($string, $delimiter)

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

Arguments

  • $string mixed
  • $delimiter mixed

isAllProductsInStock

boolean CartCore::isAllProductsInStock()

isAssociatedToGroupShop

boolean ObjectModelCore::isAssociatedToGroupShop(integer $id_group_shop)

Check if current object is associated to a group shop

Arguments

  • $id_group_shop integer

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

isCarrierInRange

mixed CartCore::isCarrierInRange($id_carrier, $id_zone)

isCarrierInRange

Check if the specified carrier is in range

Arguments

  • $id_carrier mixed
  • $id_zone mixed

isCurrentlyUsed

boolean ObjectModelCore::isCurrentlyUsed(string $table, boolean $has_active_column)

This method is allow to know if a entity is currently used

Arguments

  • $table string - name of table linked to entity
  • $has_active_column boolean - true if the table has an active column

isGuestCartByCartId

boolean CartCore::isGuestCartByCartId(integer $id_cart)

isGuestCartByCartId

Arguments

  • $id_cart integer

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultiAddressDelivery

boolean CartCore::isMultiAddressDelivery()

Does the cart use multiple address

isVirtualCart

boolean CartCore::isVirtualCart($strict)

Check if cart contains only virtual products

Arguments

  • $strict mixed

lastNoneOrderedCart

mixed CartCore::lastNoneOrderedCart($id_customer)

Arguments

  • $id_customer mixed

makeTranslationFields

mixed ObjectModelCore::makeTranslationFields($fields, $fieldsArray, $id_language)

Arguments

  • $fields mixed
  • $fieldsArray mixed
  • $id_language mixed

nbProducts

mixed CartCore::nbProducts()

Return cart products quantity

orderExists

boolean CartCore::orderExists()

Check if order has already been placed

removeCartRule

mixed CartCore::removeCartRule($id_cart_rule)

Arguments

  • $id_cart_rule mixed

replaceZeroByShopName

mixed CartCore::replaceZeroByShopName($echo, $tr)

Arguments

  • $echo mixed
  • $tr mixed

save

boolean ObjectModelCore::save(boolean $null_values, boolean $autodate)

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

Retrocompatibility for classes without $definition static Remove this in 1.6 !

setDeliveryOption

mixed CartCore::setDeliveryOption($delivery_option)

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

Arguments

  • $delivery_option mixed

setNoMultishipping

mixed CartCore::setNoMultishipping()

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

setProductAddressDelivery

mixed CartCore::setProductAddressDelivery($id_product, $id_product_attribute, $old_id_address_delivery, $new_id_address_delivery)

Arguments

  • $id_product mixed
  • $id_product_attribute mixed
  • $old_id_address_delivery mixed
  • $new_id_address_delivery mixed

setWsCartRows

mixed CartCore::setWsCartRows($values)

Arguments

  • $values mixed

simulateCarrierSelectedOutput

mixed CartCore::simulateCarrierSelectedOutput()

simulateCarriersOutput

mixed CartCore::simulateCarriersOutput(\Country $default_country, boolean $flush)

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

Arguments

  • $default_country Country
  • $flush boolean - Force flushing cache

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

mixed CartCore::update($null_values)

Arguments

  • $null_values mixed

updateQty

mixed CartCore::updateQty(integer $quantity, integer $id_product, integer $id_product_attribute, $id_customization, $id_address_delivery, string $operator, \Shop $shop)

Update product quantity

Arguments

  • $quantity integer - Quantity to add (or substract)
  • $id_product integer - Product ID
  • $id_product_attribute integer - Attribute ID if needed
  • $id_customization mixed
  • $id_address_delivery mixed
  • $operator string - Indicate if quantity must be increased or decreased
  • $shop Shop

validateControler

mixed ObjectModelCore::validateControler($htmlentities)

TODO: refactor rename all calls to this to validateController

Arguments

  • $htmlentities mixed

validateController

mixed ObjectModelCore::validateController($htmlentities)

Arguments

  • $htmlentities mixed

validateField

boolean|string ObjectModelCore::validateField(string $field, mixed $value, integer $id_lang)

Validate a single field

Arguments

  • $field string - Field name
  • $value mixed - Field value
  • $id_lang integer

validateFields

boolean|string ObjectModelCore::validateFields(boolean $die, boolean $error_return)

Check for fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean

validateFieldsLang

boolean|string ObjectModelCore::validateFieldsLang(boolean $die, boolean $error_return)

Check for multilingual fields validity before database interaction

Arguments

  • $die boolean
  • $error_return boolean