Skip to content

Latest commit

 

History

History
2625 lines (1354 loc) · 63.2 KB

class.DiscountCore.md

File metadata and controls

2625 lines (1354 loc) · 63.2 KB

Class DiscountCore

  • Class name: DiscountCore
  • Parent class: CartRule
  • Warning: this class is deprecated. This means that this class will likely be removed in a future version.
  • Source: classes/Discount.php line 30

Contents

Constants

Properties

Methods

Constants

AMOUNT

const AMOUNT = 2
  • Warning: this constant is deprecated. This means that this constant will likely be removed in a future version.
  • Source: classes/Discount.php line 33.

FREE_SHIPPING

const FREE_SHIPPING = 3
  • Warning: this constant is deprecated. This means that this constant will likely be removed in a future version.
  • Source: classes/Discount.php line 34.

PERCENT

const PERCENT = 1
  • Warning: this constant is deprecated. This means that this constant will likely be removed in a future version.
  • Source: classes/Discount.php line 32.

Properties

$active

public mixed $active = 1

$carrier_restriction

public mixed $carrier_restriction

$cart_rule_restriction

public mixed $cart_rule_restriction

$code

public mixed $code

$country_restriction

public mixed $country_restriction

$date_add

public mixed $date_add

$date_from

public mixed $date_from

$date_to

public mixed $date_to

$date_upd

public mixed $date_upd

$definition

public mixed $definition = array('table' => 'cart_rule', 'primary' => 'id_cart_rule', 'multilang' => true, 'fields' => array('id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'date_from' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), 'date_to' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'required' => true), 'description' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 65534), 'quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'quantity_per_user' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'priority' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'partial_use' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'code' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 254), 'minimum_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'minimum_amount_tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'minimum_amount_currency' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'minimum_amount_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'country_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'carrier_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'group_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'cart_rule_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'product_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'shop_restriction' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'free_shipping' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'reduction_percent' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPercentage'), 'reduction_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat'), 'reduction_tax' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'reduction_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'reduction_product' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'gift_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'gift_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'highlight' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 254)))

$description

public mixed $description

$free_shipping

public mixed $free_shipping

$gift_product

public mixed $gift_product

$gift_product_attribute

public mixed $gift_product_attribute

$group_restriction

public mixed $group_restriction

$highlight

public mixed $highlight

$id

public mixed $id

$id_customer

public mixed $id_customer

$minimum_amount

public mixed $minimum_amount

$minimum_amount_currency

public mixed $minimum_amount_currency

$minimum_amount_shipping

public mixed $minimum_amount_shipping

$minimum_amount_tax

public mixed $minimum_amount_tax

$name

public mixed $name

$only_one_gift

protected mixed $only_one_gift = array()

$partial_use

public mixed $partial_use = 1

$priority

public mixed $priority = 1

$product_restriction

public mixed $product_restriction

$quantity

public mixed $quantity = 1

$quantity_per_user

public mixed $quantity_per_user = 1

$reduction_amount

public mixed $reduction_amount

$reduction_currency

public mixed $reduction_currency

$reduction_percent

public mixed $reduction_percent

$reduction_product

public mixed $reduction_product

$reduction_tax

public mixed $reduction_tax

$shop_restriction

public mixed $shop_restriction

$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_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

$webserviceParameters

protected array $webserviceParameters = array()

Methods

__call

mixed DiscountCore::__call($method, $args)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 124

Arguments

  • $method mixed
  • $args mixed

__construct

mixed ObjectModelCore::__construct(integer $id, integer $id_lang, integer $id_shop)

Build object

Arguments

  • $id integer - Existing object id in order to load object (optional)
  • $id_lang integer - Required if object is multilingual (optional)
  • $id_shop integer - ID shop for objects with multishop on langs

__get

mixed DiscountCore::__get($key)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 36

Arguments

  • $key mixed

__set

mixed DiscountCore::__set($key, $value)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 76

Arguments

  • $key mixed
  • $value mixed

add

mixed DiscountCore::add($autodate, $nullValues, $categories)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 136

Arguments

  • $autodate mixed
  • $nullValues mixed
  • $categories mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

array_uintersect

mixed CartRuleCore::array_uintersect($array1, $array2)

Arguments

  • $array1 mixed
  • $array2 mixed

array_uintersect_compare

mixed CartRuleCore::array_uintersect_compare($a, $b)

Arguments

  • $a mixed
  • $b mixed

associateTo

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

This function associate an item to its context

Arguments

  • $id_shops integer|array

autoAddToCart

mixed CartRuleCore::autoAddToCart(\Context|null $context)

Arguments

autoRemoveFromCart

mixed CartRuleCore::autoRemoveFromCart($context)

Arguments

  • $context mixed

cartRuleExists

boolean CartRuleCore::cartRuleExists($name)

Arguments

  • $name mixed

checkProductRestrictions

mixed CartRuleCore::checkProductRestrictions(\Context $context, $return_products, $display_error)

Arguments

  • $context Context
  • $return_products mixed
  • $display_error mixed

checkValidity

boolean|mixed|string CartRuleCore::checkValidity(\Context $context, boolean $alreadyInCart, boolean $display_error)

Check if this cart rule can be applied

Arguments

  • $context Context
  • $alreadyInCart boolean - Check if the voucher is already on the cart
  • $display_error boolean - Display error

cleanCache

mixed CartRuleCore::cleanCache()

Make sure caches are empty Must be called before calling multiple time getContextualValue()

cleanProductRuleIntegrity

mixed CartRuleCore::cleanProductRuleIntegrity($type, $list)

Arguments

  • $type mixed
  • $list mixed

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

copyConditions

mixed CartRuleCore::copyConditions(integer $id_cart_rule_source, integer $id_cart_rule_destination)

Copy conditions from one cart rule to an other

Arguments

  • $id_cart_rule_source integer
  • $id_cart_rule_destination integer

createOrderDiscount

mixed DiscountCore::createOrderDiscount($order, $productList, $qtyList, $name, $shipping_cost, $id_category, $subcategory)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 203

Arguments

  • $order mixed
  • $productList mixed
  • $qtyList mixed
  • $name mixed
  • $shipping_cost mixed
  • $id_category mixed
  • $subcategory mixed

delete

mixed CartRuleCore::delete()

deleteByIdCustomer

boolean CartRuleCore::deleteByIdCustomer($id_customer)

Arguments

  • $id_customer 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

discountExists

mixed DiscountCore::discountExists($discountName, $id_discount)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 195

Arguments

  • $discountName mixed
  • $id_discount mixed

display

mixed DiscountCore::display($value, $type, $currency)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 255

Arguments

  • $value mixed
  • $type mixed
  • $currency 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

getAssociatedRestrictions

mixed CartRuleCore::getAssociatedRestrictions($type, $active_only, $i18n)

Arguments

  • $type mixed
  • $active_only mixed
  • $i18n mixed

getAssociatedShops

array ObjectModelCore::getAssociatedShops()

Get the list of associated id_shop

getCartRuleCombinations

mixed CartRuleCore::getCartRuleCombinations()

getCartsRuleByCode

array CartRuleCore::getCartsRuleByCode($name, $id_lang)

Arguments

  • $name mixed
  • $id_lang mixed

getContextualValue

float|integer|string CartRuleCore::getContextualValue(boolean $use_tax, \Context $context, $filter, $package, boolean $use_cache)

The reduction value is POSITIVE

Arguments

  • $use_tax boolean
  • $context Context
  • $filter mixed
  • $package mixed
  • $use_cache boolean - Allow using cache to avoid multiple free gift using multishipping

getCustomerCartRules

array CartRuleCore::getCustomerCartRules($id_lang, $id_customer, boolean $active, boolean $includeGeneric, boolean $inStock, \Cart|null $cart)

Arguments

  • $id_lang mixed
  • $id_customer mixed
  • $active boolean
  • $includeGeneric boolean
  • $inStock boolean
  • $cart Cart|null

getCustomerDiscounts

mixed DiscountCore::getCustomerDiscounts($id_lang, $id_customer, $active, $includeGenericOnes, $hasStock, \Cart $cart)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 164

Arguments

  • $id_lang mixed
  • $id_customer mixed
  • $active mixed
  • $includeGenericOnes mixed
  • $hasStock mixed
  • $cart Cart

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

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.

getIdByCode

integer|boolean CartRuleCore::getIdByCode(string $code)

Retrieves the id associated to the given code

Arguments

  • $code string

getIdByName

mixed DiscountCore::getIdByName($code)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 156

Arguments

  • $code mixed

getProductRuleGroups

array CartRuleCore::getProductRuleGroups()

getProductRules

array CartRuleCore::getProductRules($id_product_rule_group)

Arguments

  • $id_product_rule_group mixed

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)

getValue

mixed DiscountCore::getValue($nb_discounts, $order_total_products, $shipping_fees, $id_cart, $useTax, \Currency $currency, \Shop $shop)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 180

Arguments

  • $nb_discounts mixed
  • $order_total_products mixed
  • $shipping_fees mixed
  • $id_cart mixed
  • $useTax mixed
  • $currency Currency
  • $shop Shop

getVouchersToCartDisplay

mixed DiscountCore::getVouchersToCartDisplay($id_lang, $id_customer)
  • Visibility: public
  • This method is static.
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 172

Arguments

  • $id_lang mixed
  • $id_customer mixed

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

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

isFeatureActive

boolean CartRuleCore::isFeatureActive()

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isMultishop

mixed ObjectModelCore::isMultishop()

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

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

toggleStatus

boolean ObjectModelCore::toggleStatus()

Toggle object status in database

update

mixed DiscountCore::update($autodate, $nullValues, $categories)
  • Visibility: public
  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.
  • Source: classes/Discount.php line 146

Arguments

  • $autodate mixed
  • $nullValues mixed
  • $categories mixed

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

usedByCustomer

boolean CartRuleCore::usedByCustomer($id_customer)

Arguments

  • $id_customer mixed

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