Skip to content

Latest commit

 

History

History
2949 lines (1437 loc) · 64.4 KB

class.OrderCore.md

File metadata and controls

2949 lines (1437 loc) · 64.4 KB

Class OrderCore

Contents

Properties

Methods

Properties

$_historyCache

protected mixed $_historyCache = array()

$_taxCalculationMethod

protected mixed $_taxCalculationMethod = PS_TAX_EXC

$carrier_tax_rate

public float $carrier_tax_rate

$conversion_rate

public float $conversion_rate

$date_add

public string $date_add

$date_upd

public string $date_upd

$delivery_date

public string $delivery_date

$delivery_number

public integer $delivery_number

$fieldsRequired

protected mixed $fieldsRequired = array('conversion_rate', 'id_address_delivery', 'id_address_invoice', 'id_cart', 'id_currency', 'id_lang', 'id_customer', 'id_carrier', 'payment', 'total_paid', 'total_paid_real', 'total_products', 'total_products_wt')

$fieldsValidate

protected mixed $fieldsValidate = array('id_address_delivery' => 'isUnsignedId', 'id_address_invoice' => 'isUnsignedId', 'id_cart' => 'isUnsignedId', 'id_currency' => 'isUnsignedId', 'id_group_shop' => 'isUnsignedId', 'id_shop' => 'isUnsignedId', 'id_lang' => 'isUnsignedId', 'id_customer' => 'isUnsignedId', 'id_carrier' => 'isUnsignedId', 'id_warehouse' => 'isUnsignedId', 'secure_key' => 'isMd5', 'payment' => 'isGenericName', 'recyclable' => 'isBool', 'gift' => 'isBool', 'gift_message' => 'isMessage', 'total_discounts' => 'isPrice', 'total_discounts_tax_incl' => 'isPrice', 'total_discounts_tax_excl' => 'isPrice', 'total_paid' => 'isPrice', 'total_paid_tax_incl' => 'isPrice', 'total_paid_tax_excl' => 'isPrice', 'total_paid_real' => 'isPrice', 'total_products' => 'isPrice', 'total_products_wt' => 'isPrice', 'total_shipping' => 'isPrice', 'total_shipping_tax_incl' => 'isPrice', 'total_shipping_tax_excl' => 'isPrice', 'carrier_tax_rate' => 'isFloat', 'total_wrapping' => 'isPrice', 'total_wrapping_tax_incl' => 'isPrice', 'total_wrapping_tax_excl' => 'isPrice', 'shipping_number' => 'isUrl', 'conversion_rate' => 'isFloat')

$gift

public boolean $gift

$gift_message

public string $gift_message

$id_address_delivery

public integer $id_address_delivery

$id_address_invoice

public integer $id_address_invoice

$id_carrier

public integer $id_carrier

$id_cart

public integer $id_cart

$id_currency

public integer $id_currency

$id_customer

public integer $id_customer

$id_group_shop

public mixed $id_group_shop

$id_lang

public integer $id_lang

$id_shop

public mixed $id_shop

$id_warehouse

public integer $id_warehouse

$identifier

protected mixed $identifier = 'id_order'

$invoice_date

public string $invoice_date

$invoice_number

public integer $invoice_number

$module

public string $module

$payment

public string $payment

$recyclable

public boolean $recyclable = 1

$reference

public string $reference

$secure_key

public string $secure_key

$shipping_number

public string $shipping_number

$table

protected mixed $table = 'orders'

$tables

protected mixed $tables = array('orders')

$total_discounts

public float $total_discounts

$total_discounts_tax_excl

public mixed $total_discounts_tax_excl

$total_discounts_tax_incl

public mixed $total_discounts_tax_incl

$total_paid

public float $total_paid

$total_paid_real

public float $total_paid_real

$total_paid_tax_excl

public float $total_paid_tax_excl

$total_paid_tax_incl

public float $total_paid_tax_incl

$total_products

public float $total_products

$total_products_wt

public float $total_products_wt

$total_shipping

public float $total_shipping

$total_shipping_tax_excl

public float $total_shipping_tax_excl

$total_shipping_tax_incl

public float $total_shipping_tax_incl

$total_wrapping

public float $total_wrapping

$total_wrapping_tax_excl

public float $total_wrapping_tax_excl

$total_wrapping_tax_incl

public float $total_wrapping_tax_incl

$valid

public boolean $valid

$webserviceParameters

protected mixed $webserviceParameters = array('objectMethods' => array('add' => 'addWs'), 'objectNodeName' => 'order', 'objectsNodeName' => 'orders', 'fields' => array('id_address_delivery' => array('xlink_resource' => 'addresses'), 'id_address_invoice' => array('xlink_resource' => 'addresses'), 'id_cart' => array('xlink_resource' => 'carts'), 'id_currency' => array('xlink_resource' => 'currencies'), 'id_lang' => array('xlink_resource' => 'languages'), 'id_customer' => array('xlink_resource' => 'customers'), 'id_carrier' => array('xlink_resource' => 'carriers'), 'module' => array('required' => true), 'invoice_number' => array(), 'invoice_date' => array(), 'delivery_number' => array(), 'delivery_date' => array(), 'valid' => array(), 'current_state' => array('getter' => 'getCurrentState', 'setter' => 'setCurrentState', 'xlink_resource' => 'order_states'), 'date_add' => array(), 'date_upd' => array()), 'associations' => array('order_rows' => array('resource' => 'order_row', 'setter' => false, 'virtual_entity' => true, 'fields' => array('id' => array(), 'product_id' => array('required' => true), 'product_attribute_id' => array('required' => true), 'product_quantity' => array('required' => true), 'product_name' => array('setter' => false), 'product_price' => array('setter' => false)))))

$_cache

protected mixed $_cache = array()

$fieldsRequiredDatabase

protected \fieldsRequiredDatabase $fieldsRequiredDatabase = null

$fieldsRequiredLang

protected array $fieldsRequiredLang = array()

$fieldsSize

protected array $fieldsSize = array()

$fieldsSizeLang

protected array $fieldsSizeLang = array()

$fieldsValidateLang

protected array $fieldsValidateLang = array()

$id

public integer $id

$image_dir

protected string $image_dir = null

$image_format

protected string $image_format = 'jpg'

$langMultiShop

protected mixed $langMultiShop = false

Methods

__construct

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

Arguments

  • $id mixed
  • $id_lang mixed

_deleteProduct

mixed OrderCore::_deleteProduct($orderDetail, $quantity)

Arguments

  • $orderDetail mixed
  • $quantity mixed

add

mixed ObjectModelCore::add($autodate, $nullValues)

Add current object to database

return boolean Insertion result

Arguments

  • $autodate mixed
  • $nullValues mixed

addCartRule

mixed OrderCore::addCartRule($id_cart_rule, $name, $value)

Arguments

  • $id_cart_rule mixed
  • $name mixed
  • $value mixed

addDiscount

mixed OrderCore::addDiscount($id_cart_rule, $name, $value)

Arguments

  • $id_cart_rule mixed
  • $name mixed
  • $value mixed

addFieldsRequiredDatabase

mixed ObjectModelCore::addFieldsRequiredDatabase($fields)

Arguments

  • $fields mixed

addOrderPayment

boolean OrderCore::addOrderPayment(float $amount_paid, string $payment_method, string $payment_transaction_id, \Currency $currency, string $date)

This method allows to add a payment to the current order

Arguments

  • $amount_paid float
  • $payment_method string
  • $payment_transaction_id string
  • $currency Currency
  • $date string

addWs

mixed OrderCore::addWs($autodate, $nullValues)

Arguments

  • $autodate mixed
  • $nullValues 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

clearCache

mixed ObjectModelCore::clearCache($all)

Arguments

  • $all mixed

delete

mixed ObjectModelCore::delete()

Delete current object from database

return boolean Deletion result

deleteAssociations

mixed OrderCore::deleteAssociations()

deleteCustomization

mixed OrderCore::deleteCustomization($id_customization, $quantity, $orderDetail)

Arguments

  • $id_customization mixed
  • $quantity mixed
  • $orderDetail mixed

deleteImage

boolean ObjectModelCore::deleteImage()

Delete images associated with the object

deleteProduct

mixed OrderCore::deleteProduct($order, $orderDetail, $quantity)

Arguments

  • $order mixed
  • $orderDetail mixed
  • $quantity mixed

deleteSelection

mixed ObjectModelCore::deleteSelection($selection)

Delete several objects from database

return boolean Deletion result

Arguments

  • $selection mixed

displayFieldName

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

Arguments

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

duplicateShops

mixed ObjectModelCore::duplicateShops($id)

Arguments

  • $id mixed

existsInDatabase

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

Specify if an ObjectModel is already in database

Arguments

  • $id_entity mixed - entity id
  • $table mixed

generateReference

String OrderCore::generateReference()

Gennerate a unique reference for orders generated with the same cart id This references, is usefull for check payment

getByDelivery

mixed OrderCore::getByDelivery($id_delivery)

Arguments

  • $id_delivery mixed

getCartIdStatic

integer OrderCore::getCartIdStatic(integer $id_order, integer $id_customer)

Arguments

  • $id_order integer
  • $id_customer integer - optionnal

getCartRules

mixed OrderCore::getCartRules()

getCurrentState

array OrderCore::getCurrentState()

Get current order state (eg. Awaiting payment, Delivered.

..)

getCurrentStateFull

array OrderCore::getCurrentStateFull($id_lang)

Get current order state name (eg. Awaiting payment, Delivered.

..)

Arguments

  • $id_lang mixed

getCustomerNbOrders

array OrderCore::getCustomerNbOrders(integer $id_customer)

Get customer orders number

Arguments

  • $id_customer integer - Customer id

getCustomerOrders

array OrderCore::getCustomerOrders(integer $id_customer, boolean $showHiddenStatus, \Context $context)

Get customer orders

Arguments

  • $id_customer integer - Customer id
  • $showHiddenStatus boolean - Display or not hidden order statuses
  • $context Context

getDiscounts

mixed OrderCore::getDiscounts($details)

Arguments

  • $details mixed

getDiscountsCustomer

mixed OrderCore::getDiscountsCustomer($id_customer, $id_cart_rule)

Arguments

  • $id_customer mixed
  • $id_cart_rule mixed

getDocuments

array OrderCore::getDocuments()

Returns the correct product taxes breakdown.

Get all documents linked to the current order

getEcoTaxTaxesBreakdown

array OrderCore::getEcoTaxTaxesBreakdown()

Returns the ecotax taxes breakdown

getFields

mixed OrderCore::getFields()

getFieldsRequiredDatabase

mixed ObjectModelCore::getFieldsRequiredDatabase($all)

Arguments

  • $all mixed

getFieldsValidateLang

array ObjectModelCore::getFieldsValidateLang()

Get list of fields related to language to validate

getFirstMessage

mixed OrderCore::getFirstMessage()

getHistory

array OrderCore::getHistory(integer $id_lang, $id_order_state, $no_hidden)

Get order history

Arguments

  • $id_lang integer - Language id
  • $id_order_state mixed
  • $no_hidden mixed

getIdentifier

string ObjectModelCore::getIdentifier()

Get object identifier name

getInvoice

mixed OrderCore::getInvoice(integer $id_invoice)

Arguments

  • $id_invoice integer

getInvoicesCollection

array OrderCore::getInvoicesCollection()

Get all invoices for the current order

getLastInvoiceNumber

mixed OrderCore::getLastInvoiceNumber()

getNextOrderId

integer OrderCore::getNextOrderId()

This method return the ID of the next order

getNumberOfDays

mixed OrderCore::getNumberOfDays()

getOrderByCartId

array OrderCore::getOrderByCartId(integer $id_cart)

Get an order by its cart id

Arguments

  • $id_cart integer - Cart id

getOrderDetailList

array OrderCore::getOrderDetailList()

Get the an order detail list of the current order

getOrderIdsByStatus

mixed OrderCore::getOrderIdsByStatus($id_order_state)

Arguments

  • $id_order_state mixed

getOrderPaymentCollection

array OrderCore::getOrderPaymentCollection()

This method allows to get all Order Payment for the current order

getOrdersIdByDate

mixed OrderCore::getOrdersIdByDate($date_from, $date_to, $id_customer, $type)

Arguments

  • $date_from mixed
  • $date_to mixed
  • $id_customer mixed
  • $type mixed

getOrdersIdInvoiceByDate

mixed OrderCore::getOrdersIdInvoiceByDate($date_from, $date_to, $id_customer, $type)

Arguments

  • $date_from mixed
  • $date_to mixed
  • $id_customer mixed
  • $type mixed

getOrdersWithInformations

mixed OrderCore::getOrdersWithInformations($limit, \Context $context)

Arguments

getPreviousOrderId

integer OrderCore::getPreviousOrderId()

This method return the ID of the previous order

getProductTaxesBreakdown

array OrderCore::getProductTaxesBreakdown()

Returns the correct product taxes breakdown.

getProducts

array OrderCore::getProducts($products, $selectedProducts, $selectedQty)

Get order products

Arguments

  • $products mixed
  • $selectedProducts mixed
  • $selectedQty mixed

getProductsDetail

mixed OrderCore::getProductsDetail()

getReturn

mixed OrderCore::getReturn()

getShipping

mixed OrderCore::getShipping()

getShippingTaxesBreakdown

array OrderCore::getShippingTaxesBreakdown()

Returns the shipping taxes breakdown

getTaxCalculationMethod

mixed OrderCore::getTaxCalculationMethod()

getTaxesAverageUsed

mixed OrderCore::getTaxesAverageUsed()

getTotalPaid

float OrderCore::getTotalPaid(\Currency $currency)

Get total paid

Arguments

  • $currency Currency - currency used for the total paid of the current order

getTotalProductsWithTaxes

\Product OrderCore::getTotalProductsWithTaxes($products)

Get product total with taxes

Arguments

  • $products mixed

getTotalProductsWithoutTaxes

\Product OrderCore::getTotalProductsWithoutTaxes($products)

Get product total without taxes

Arguments

  • $products mixed

getTotalWeight

mixed OrderCore::getTotalWeight()

getTranslationsFields

mixed ObjectModelCore::getTranslationsFields(array $fieldsArray)

Prepare multilingual fields for database insertion

Arguments

  • $fieldsArray array - Multilingual fields to prepare return array Prepared fields for database insertion

getValidationRules

array ObjectModelCore::getValidationRules(string $className)

Returns object validation rules (fields validity)

Arguments

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

getVirtualProducts

integer OrderCore::getVirtualProducts()

Count virtual products in order

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

getWrappingTaxesBreakdown

array OrderCore::getWrappingTaxesBreakdown()

Returns the wrapping taxes breakdown

getWsOrderRows

mixed OrderCore::getWsOrderRows()

hasBeenDelivered

mixed OrderCore::hasBeenDelivered()

hasBeenPaid

mixed OrderCore::hasBeenPaid()

hasBeenShipped

mixed OrderCore::hasBeenShipped()

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

isAssociatedAtGuest

mixed OrderCore::isAssociatedAtGuest($email)

Arguments

  • $email mixed

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

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

isInPreparation

mixed OrderCore::isInPreparation()

isLangMultishop

mixed ObjectModelCore::isLangMultishop()

isReturnable

mixed OrderCore::isReturnable()

isVirtual

boolean OrderCore::isVirtual(boolean $strict)

Check if order contains (only) virtual products

Arguments

  • $strict boolean - If false return true if there are at least one product virtual

makeTranslationFields

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

Arguments

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

orderContainProduct

mixed OrderCore::orderContainProduct($id_product)

Arguments

  • $id_product mixed

printPDFIcons

mixed OrderCore::printPDFIcons($id_order, $tr)

Arguments

  • $id_order mixed
  • $tr mixed

save

mixed ObjectModelCore::save($nullValues, $autodate)

Save current object to database (add or update)

return boolean Insertion result

Arguments

  • $nullValues mixed
  • $autodate mixed

setCurrentState

mixed OrderCore::setCurrentState(integer $id_order_state, integer $id_employee)

Set current order state

Arguments

  • $id_order_state integer
  • $id_employee integer - (/!\ not optional except for Webservice.

setDelivery

mixed OrderCore::setDelivery()

setInvoice

mixed OrderCore::setInvoice()

setProductCurrentStock

mixed OrderCore::setProductCurrentStock($product)

This method allow to add stock information on a product detail

Arguments

  • $product mixed

setProductCustomizedDatas

mixed OrderCore::setProductCustomizedDatas($product, $customized_datas)

Arguments

  • $product mixed
  • $customized_datas mixed

setProductImageInformations

mixed OrderCore::setProductImageInformations($product)

This method allow to add image information on a product detail

Arguments

  • $product mixed

setProductPrices

mixed OrderCore::setProductPrices($row)

Arguments

  • $row mixed

toggleStatus

mixed ObjectModelCore::toggleStatus()

Toggle object status in database

return boolean Update result

update

boolean ObjectModelCore::update($nullValues)

Update current object to database

Arguments

  • $nullValues mixed

updateShippingCost

boolean OrderCore::updateShippingCost(float $amount)

This method allows to change the shipping cost of the current order

Arguments

  • $amount float

useOneAfterAnotherTaxComputationMethod

boolean OrderCore::useOneAfterAnotherTaxComputationMethod()

This method returns true if at least one order details uses the One After Another tax computation method.

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

validateFields

mixed ObjectModelCore::validateFields($die, $errorReturn)

Check for fields validity before database interaction

Arguments

  • $die mixed
  • $errorReturn mixed

validateFieldsLang

mixed ObjectModelCore::validateFieldsLang($die, $errorReturn)

Check for multilingual fields validity before database interaction

Arguments

  • $die mixed
  • $errorReturn mixed