Skip to content

Latest commit

 

History

History
2702 lines (1353 loc) · 60.2 KB

class.CarrierCore.md

File metadata and controls

2702 lines (1353 loc) · 60.2 KB

Class CarrierCore

Contents

Constants

Properties

Methods

Constants

ALL_CARRIERS

const ALL_CARRIERS = 5

CARRIERS_MODULE

const CARRIERS_MODULE = 2

CARRIERS_MODULE_NEED_RANGE

const CARRIERS_MODULE_NEED_RANGE = 3

PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE

const PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE = 4

PS_CARRIERS_ONLY

const PS_CARRIERS_ONLY = 1

getCarriers method filter

SHIPPING_METHOD_DEFAULT

const SHIPPING_METHOD_DEFAULT = 0

SHIPPING_METHOD_FREE

const SHIPPING_METHOD_FREE = 3

SHIPPING_METHOD_PRICE

const SHIPPING_METHOD_PRICE = 2

SHIPPING_METHOD_WEIGHT

const SHIPPING_METHOD_WEIGHT = 1

SORT_BY_ASC

const SORT_BY_ASC = 0

SORT_BY_DESC

const SORT_BY_DESC = 1

SORT_BY_POSITION

const SORT_BY_POSITION = 1

SORT_BY_PRICE

const SORT_BY_PRICE = 0

Properties

$active

public boolean $active = true

$cache_tax_rule

protected mixed $cache_tax_rule = array()

$definition

public mixed $definition = array('table' => 'carrier', 'primary' => 'id_carrier', 'multilang' => true, 'multilang_shop' => true, 'fields' => array('id_reference' => array('type' => self::TYPE_INT), 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isCarrierName', 'required' => true, 'size' => 64), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'required' => true), 'is_free' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'url' => array('type' => self::TYPE_STRING, 'validate' => 'isAbsoluteUrl'), 'shipping_handling' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'shipping_external' => array('type' => self::TYPE_BOOL), 'range_behavior' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'shipping_method' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'max_width' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'max_height' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'max_depth' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'max_weight' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'grade' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'size' => 1), 'external_module_name' => array('type' => self::TYPE_STRING, 'size' => 64), 'is_module' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'need_range' => array('type' => self::TYPE_BOOL), 'position' => array('type' => self::TYPE_INT), 'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'delay' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128)))

$delay

public string $delay

$deleted

public boolean $deleted

$external_module_name

public string $external_module_name = null

$grade

public integer $grade

$id_reference

public integer $id_reference

$is_free

public boolean $is_free = false

$is_module

public boolean $is_module

$max_depth

public integer $max_depth

$max_height

public integer $max_height

$max_weight

public integer $max_weight

$max_width

public integer $max_width

$name

public string $name

$need_range

public boolean $need_range

$position

public integer $position

$price_by_price

protected mixed $price_by_price = array()

$price_by_price2

protected mixed $price_by_price2 = array()

$price_by_weight

protected mixed $price_by_weight = array()

$price_by_weight2

protected mixed $price_by_weight2 = array()

$range_behavior

public integer $range_behavior

$shipping_external

public boolean $shipping_external

$shipping_handling

public boolean $shipping_handling = true

$shipping_method

public integer $shipping_method

$url

public string $url

$webserviceParameters

protected mixed $webserviceParameters = array('fields' => array('deleted' => array(), 'is_module' => array(), 'id_tax_rules_group' => array('getter' => 'getIdTaxRulesGroup', 'setter' => 'setTaxRulesGroup', 'xlink_resource' => array('resourceName' => 'tax_rules_group'))))

$db

protected \Db $db = false

$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()

$get_shop_from_context

protected mixed $get_shop_from_context = true

$id

public integer $id

$id_lang

protected integer $id_lang = null

$id_shop

protected mixed $id_shop = null

$id_shop_list

public mixed $id_shop_list = null

$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()

$update_fields

protected array $update_fields = null

Methods

__construct

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

Arguments

  • $id mixed
  • $id_lang mixed

add

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

Arguments

  • $autodate mixed
  • $null_values mixed

addDeliveryPrice

boolean CarrierCore::addDeliveryPrice($price_list)

Add new delivery prices

Arguments

  • $price_list mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addZone

mixed CarrierCore::addZone($id_zone)

Add zone

Arguments

  • $id_zone mixed

assignGroupToAllCarriers

mixed CarrierCore::assignGroupToAllCarriers(integer|array $id_group_list, array $exception)

Assign one (ore more) group to all carriers

Arguments

  • $id_group_list integer|array - group id or list of group ids
  • $exception array - list of id carriers to ignore

associateTo

boolean ObjectModelCore::associateTo(integer|array $id_shops)

This function associate an item to its context

Arguments

  • $id_shops integer|array

checkCarrierZone

mixed CarrierCore::checkCarrierZone($id_carrier, $id_zone)

Arguments

  • $id_carrier mixed
  • $id_zone mixed

checkDeliveryPriceByPrice

float CarrierCore::checkDeliveryPriceByPrice($id_carrier, $order_total, integer $id_zone, integer $id_currency)

Check delivery prices for a given order

Arguments

  • $id_carrier mixed
  • $order_total mixed
  • $id_zone integer - Zone id (for customer delivery address)
  • $id_currency integer

checkDeliveryPriceByWeight

mixed CarrierCore::checkDeliveryPriceByWeight($id_carrier, $total_weight, $id_zone)

Arguments

  • $id_carrier mixed
  • $total_weight mixed
  • $id_zone mixed

cleanPositions

boolean CarrierCore::cleanPositions()

Reorders carrier positions.

Called after deleting a carrier.

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

copyCarrierData

mixed CarrierCore::copyCarrierData($old_id)

Copy old carrier informations when update carrier

Arguments

  • $old_id mixed

delete

mixed CarrierCore::delete()

deleteDeliveryPrice

boolean CarrierCore::deleteDeliveryPrice($range_table)

Clean delivery prices (weight/price)

Arguments

  • $range_table mixed

deleteImage

boolean ObjectModelCore::deleteImage($force_delete)

Delete images associated with the object

Arguments

  • $force_delete mixed

deleteSelection

boolean ObjectModelCore::deleteSelection(array $selection)

Delete several objects from database

Arguments

  • $selection array

deleteTaxRulesGroup

mixed CarrierCore::deleteTaxRulesGroup(array $shops)

Arguments

  • $shops array

deleteZone

mixed CarrierCore::deleteZone($id_zone)

Delete zone

Arguments

  • $id_zone mixed

displayFieldName

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

Arguments

  • $field mixed
  • $class mixed
  • $htmlentities mixed
  • $context Context

duplicateObject

\new ObjectModelCore::duplicateObject()

Duplicate current object to database

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 $type, integer $id_lang)

Arguments

  • $type integer - FORMAT_COMMON or FORMAT_LANG or FORMAT_SHOP
  • $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

getAssociatedShops

array ObjectModelCore::getAssociatedShops()

Get the list of associated id_shop

getAvailableCarrierList

array CarrierCore::getAvailableCarrierList(\Product $product, $id_warehouse, $id_address_delivery, $id_shop, $cart)

For a given {product, warehouse}, gets the carrier available

Arguments

  • $product Product - The id of the product, or an array with at least the package size and weight
  • $id_warehouse mixed
  • $id_address_delivery mixed
  • $id_shop mixed
  • $cart mixed

getCarrierByReference

mixed CarrierCore::getCarrierByReference($id_reference)

Get carrier using the reference id

Arguments

  • $id_reference mixed

getCarriers

array CarrierCore::getCarriers(integer $id_lang, boolean $active, $delete, $id_zone, $ids_group, $modules_filters)

Get all carriers in a given language

Arguments

  • $id_lang integer - Language id
  • $active boolean - Returns only active carriers when true
  • $delete mixed
  • $id_zone mixed
  • $ids_group mixed
  • $modules_filters mixed

getCarriersForOrder

Array CarrierCore::getCarriersForOrder(integer $id_zone, Array $groups, $cart)

Arguments

  • $id_zone integer
  • $groups Array - group of the customer
  • $cart mixed

getDefaultCarrierSelection

\number CarrierCore::getDefaultCarrierSelection(array $carriers, $default_carrier)

Return the default carrier to use

Arguments

  • $carriers array
  • $default_carrier mixed

getDefinition

array ObjectModelCore::getDefinition(string $class, string $field)

Get object definition

Arguments

  • $class string - Name of object
  • $field string - Name of field if we want the definition of one field only

getDeliveredCountries

mixed CarrierCore::getDeliveredCountries($id_lang, $active_countries, $active_carriers, $contain_states)

Arguments

  • $id_lang mixed
  • $active_countries mixed
  • $active_carriers mixed
  • $contain_states mixed

getDeliveryPriceByPrice

float CarrierCore::getDeliveryPriceByPrice($order_total, integer $id_zone, $id_currency)

Get delivery prices for a given order

Arguments

  • $order_total mixed
  • $id_zone integer - Zone id (for customer delivery address)
  • $id_currency mixed

getDeliveryPriceByRanges

array CarrierCore::getDeliveryPriceByRanges($range_table, $id_carrier)

Get delivery prices for a given shipping method (price/weight)

Arguments

  • $range_table mixed
  • $id_carrier mixed

getDeliveryPriceByWeight

float CarrierCore::getDeliveryPriceByWeight($total_weight, integer $id_zone)

Get delivery prices for a given order

Arguments

  • $total_weight mixed
  • $id_zone integer - Zone id (for customer delivery address)

getFieldByLang

mixed ObjectModelCore::getFieldByLang($field_name, null $id_lang)

Return the field value for the specified language if the field is multilang, else the field value.

Arguments

  • $field_name mixed
  • $id_lang null

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

getFieldsShop

array ObjectModelCore::getFieldsShop()

Prepare fields for multishop Fields are not validated here, we considere they are already validated in getFields() method, this not the best solution but this is the only one possible for retro compatibility.

getGroups

array CarrierCore::getGroups()

Gets a specific group

getHigherPosition

integer CarrierCore::getHigherPosition()

Gets the highest carrier position

getIdTaxRulesGroup

mixed CarrierCore::getIdTaxRulesGroup(\Context $context)

Arguments

getIdTaxRulesGroupByIdCarrier

mixed CarrierCore::getIdTaxRulesGroupByIdCarrier($id_carrier, \Context $context)

Arguments

  • $id_carrier mixed
  • $context Context

getMaxDeliveryPriceByPrice

mixed CarrierCore::getMaxDeliveryPriceByPrice($id_zone)

Arguments

  • $id_zone mixed

getMaxDeliveryPriceByWeight

mixed CarrierCore::getMaxDeliveryPriceByWeight($id_zone)

Arguments

  • $id_zone mixed

getRangeObject

mixed CarrierCore::getRangeObject()

getRangeSuffix

mixed CarrierCore::getRangeSuffix($currency)

Arguments

  • $currency mixed

getRangeTable

mixed CarrierCore::getRangeTable()

getShippingMethod

mixed CarrierCore::getShippingMethod()

getTaxCalculator

 CarrierCore::getTaxCalculator(\Address $address)

Returns the taxes calculator associated to the carrier

Arguments

getTaxesRate

 CarrierCore::getTaxesRate(\Address $address)

Returns the taxes rate associated to the carrier

Arguments

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields($fields_array)

Arguments

  • $fields_array mixed

getValidationRules

array ObjectModelCore::getValidationRules(string $class)

Returns object validation rules (fields validity)

Arguments

  • $class 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($ws_params_attribute_name)

Arguments

  • $ws_params_attribute_name mixed

getZone

array CarrierCore::getZone($id_zone)

Get a specific zones

Arguments

  • $id_zone mixed

getZones

array CarrierCore::getZones()

Get all zones

hasMultishopEntries

boolean ObjectModelCore::hasMultishopEntries()

Check if there is more than one entries in associated shop table for current entity

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

isAssociatedToShop

boolean ObjectModelCore::isAssociatedToShop(integer $id_shop)

Check if current object is associated to a shop

Arguments

  • $id_shop integer

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

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultishop

mixed ObjectModelCore::isMultishop()

isUsed

integer CarrierCore::isUsed()

Check if carrier is used (at least one order placed)

makeTranslationFields

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

Arguments

  • $fields mixed
  • $fields_array mixed
  • $id_language mixed

save

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

Save current object to database (add or update)

Arguments

  • $null_values boolean
  • $autodate boolean

setConfiguration

mixed CarrierCore::setConfiguration(integer $id_old)

Change carrier id in delivery prices when updating a carrier

Arguments

  • $id_old integer - Old id carrier

setDefinitionRetrocompatibility

mixed ObjectModelCore::setDefinitionRetrocompatibility()

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

setFieldsToUpdate

mixed ObjectModelCore::setFieldsToUpdate(array $fields)

Set a list of specific fields to update array(field1 => true, field2 => false, langfield1 => array(1 => true, 2 => false))

Arguments

  • $fields array

setTaxRulesGroup

mixed CarrierCore::setTaxRulesGroup($id_tax_rules_group, $all_shops)

Arguments

  • $id_tax_rules_group mixed
  • $all_shops mixed

sqlDeliveryRangeShop

string CarrierCore::sqlDeliveryRangeShop($range_table, $alias)

This tricky method generates a sql clause to check if ranged data are overloaded by multishop

Arguments

  • $range_table mixed
  • $alias mixed

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

boolean ObjectModelCore::update(boolean $null_values)

Update current object to database

Arguments

  • $null_values boolean

updateMultishopTable

boolean ObjectModelCore::updateMultishopTable(string $classname, array $data, string $where, string $specific_where)

Update a table and splits the common datas and the shop datas

Arguments

  • $classname string
  • $data array
  • $where string
  • $specific_where string - Only executed for common table

updatePosition

boolean CarrierCore::updatePosition(boolean $way, integer $position)

Moves a carrier

Arguments

  • $way boolean - Up (1) or Down (0)
  • $position integer

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

validateFieldsRequiredDatabase

mixed ObjectModelCore::validateFieldsRequiredDatabase($htmlentities)

Arguments

  • $htmlentities mixed