Class TShoppingCartFo

Description

Manage the front office shoppingcart

  • author: SimpliciWeb
  • version: $Id: t_shoppingcart_fo.class.php 722 2007-11-19 09:42:42Z stephanet $

Located in /core/internal_components/front_sites/t_shoppingcart/t_shoppingcart_fo.class.php (line 60)

ObjectCached
   |
   --TShoppingCartFo
Variable Summary
Method Summary
 bool addProduct (integer $pm_id,  &$ps_id, integer $quantity, [bool $is_from_full_shopping_cart = false], integer $ps_id)
 bool delete (string $p_id)
 bool deleteForCustomerDelete (string $p_cus_id)
 bool deleteProduct (integer $p_psl_id)
 bool exist (string $p_session_id,  &$r_result_bool, bool $r_result_bool)
 bool getCountItemInShoppingCart ( &$r_result, array $r_result)
 bool getDeliveryCosts (float $p_price, string $p_cou_name,  &$r_array_delivery_costs, array $r_array_delivery_costs)
 bool getDiscountTicketStructure (string $p_pmo_title, string $p_discount_value,  &$r_result, array $r_result)
 bool getForLittle ( &$r_infos,  &$r_infos_for_floating_window, [integer $p_pm_id = 0], [integer $p_ps_id = 0], array $r_infos, array $r_infos_for_floating_window)
 bool getList ( &$r_array_products,  &$r_total_price,  &$r_total_price_without_discount,  &$r_array_for_deliverycosts, array $r_array_products, float $r_total_price, float $r_total_price_without_discount, array $r_array_for_deliverycosts)
 string getNewUid ()
 void getSavedCountry ( &$r_country_name, [string $p_default = ""], string $r_country_name)
 string getUidPrefix ()
 bool isNotValidQuantity (string $p_value)
 bool isSavedState ()
 void reNew ( &$r_change_made, bool $r_change_made)
 void setSavedCountry (string $country_name)
 integer timeToLiveInDay ()
 bool toActiveState ()
 void toLostState ()
 bool toSavedState ()
 bool toValidState ([bool $p_if_is_saved_also = false])
 bool updateToNewIfNecessary (integer $p_pma_id, integer $p_psl_id, string $p_old_pma_title, float $p_old_psl_tax_included_price, string $p_old_psl_reference, float $p_old_psl_weight, float $p_old_tty_value,  &$r_there_is_a_change_made, bool $r_there_is_a_change_made)
 bool xAdd (integer $p_pma_id,  &$p_psl_id, integer $p_quantity,  &$r_product_modified,  &$r_product_added, integer $p_psl_id, array $r_product_modified, array $r_product_added)
 bool xCleanDelete ()
 bool xGetDeliveryCostsByCountryName (string $p_type_value, float $p_price, string $p_cou_name,  &$r_array_delivery_costs, array $r_array_delivery_costs)
 bool xGetDeliveryCostsByPrice (float $p_price,  &$r_array_delivery_costs, array $r_array_delivery_costs)
 bool xGetQuantity (string $p_id, integer $p_psl_id,  &$r_quantity, integer $r_quantity)
 bool xInsert (integer $p_pma_id, integer $p_psl_id, integer $p_quantity)
 bool xIsAlreadyInserted (integer $p_psl_id,  &$r_result_bool, [string $p_state = "ACTIVE&SAVED"], bool $r_result_bool)
 bool xShoppingCartExist (string $p_session_id,  &$r_result_bool, bool $r_result_bool)
 bool xToLostState (string $p_id)
 bool xUpdate (string $p_id, integer $p_psl_id, integer $p_quantity)
Variables
bool $m_already_a_product_added = false (line 110)

A product is already added

DbConnexion $m_object_dbconnexion = null (line 67)

Database Connexion object

Format $m_object_format = null (line 73)

Format Object

TSessionScopeFo $m_object_sessionscope = NULL (line 98)

TSessionScopeFo Object

TCustomerFo $m_object_tcustomerfo = NULL (line 104)

TCustomerFo Object

TProductMasterFo $m_object_tproductmasterfo = NULL (line 86)

TProductMasterFo Object

TProductSlaveFo $m_object_tproductslavefo = NULL (line 80)

TProductSlaveFo Object

TTvaTypeFo $m_object_ttvatypefo = NULL (line 92)

TTvaTypeFo Object

integer $m_shopping_cart_time_to_life = 8 (line 320)

Shopping cart time to life (in days) for saved shopping carts

string $m_uid_prefix = "sca_" (line 326)

Unique id prefix

string $req_count =
"SELECT COUNT(*)
FROM t_shoppingcart
WHERE sca_id = '%s'
AND sca_state IN ('ACTIVE','SAVED');"
(line 276)

SQL Request : Count

string $req_delete = "delete from t_shoppingcart
where sca_id = '%s' and sca_state <> 'ACTIVE';"
(line 183)

SQL Request : Delete

string $req_delete_by_sca_id = "delete from t_shoppingcart where sca_id = '%s';" (line 256)

SQL Request : Delete by shopping cart id

string $req_delete_one = "delete from t_shoppingcart
where sca_id = '%s' and sca_psl_id=%d
and sca_state in ('ACTIVE','SAVED');"
(line 156)

SQL Request : Delete one

string $req_exist = "select sca_psl_id from t_shoppingcart
where sca_id = '%s'
and sca_psl_id = %d
and sca_state='%s';"
(line 120)

SQL Request : Exist

string $req_exist_shoppingcart = "select sca_psl_id from t_shoppingcart
where
sca_id = '%s'
and sca_state in ('ACTIVE','SAVED');"
(line 138)

SQL Request : Exist shoppingcart

string $req_exist_twostate = "select sca_psl_id from t_shoppingcart
where sca_id = '%s'
and sca_psl_id = %d
and sca_state in ('%s','%s');"
(line 129)

SQL Request : Exist two states

string $req_insert = "insert into t_shoppingcart(sca_id, sca_psl_id, sca_pma_title
, sca_psl_tax_included_price, sca_psl_original_tax_price, sca_psl_reference, sca_psl_weight
, sca_tty_value, sca_last_modified, sca_quantity, sca_attribut_string
, sca_pma_id, sca_state, sca_ses_id,
sca_pma_duration, sca_pma_start_period, sca_pma_end_period)
values('%s', %d, '%s'
, %f, %f, '%s', %f, %f, now(), %d, '%s', %d,'%s','%s',%d,'%s','%s');"
(line 263)

SQL Request : Insert

string $req_select = "SELECT
sca_id, sca_psl_id, psl_stock, sca_pma_title, sca_psl_tax_included_price, sca_psl_original_tax_price,
sca_psl_reference, sca_psl_weight, sca_tty_value,
sca_last_modified, sca_quantity, sca_attribut_string, sca_pma_id,
sca_pma_duration, sca_pma_start_period, sca_pma_end_period
FROM t_shoppingcart, t_productslave
WHERE sca_id = '%s'
AND sca_psl_id = psl_id
AND sca_state IN ('ACTIVE','SAVED');"
(line 287)

SQL Request : Select

string $req_select_delivery_weight = "" (line 249)

SQL Request : Select delivery weight

string $req_select_for_clean = "select distinct sca_id from t_shoppingcart
group by sca_id
having DATE_ADD(max(sca_last_modified), INTERVAL %d DAY) < NOW();"
(line 240)

SQL Request : Select for clean

string $req_select_little = "select
sca_psl_tax_included_price, sca_psl_original_tax_price, sca_psl_weight, sca_quantity, sca_pma_title, sca_pma_id, sca_psl_id, sca_attribut_string
from t_shoppingcart where
sca_id = '%s' and sca_state in ('ACTIVE','SAVED');"
(line 165)

SQL Request : Select little

string $req_select_quantity = "select sca_quantity
from t_shoppingcart
where sca_id = '%s' and
sca_psl_id=%d and sca_state in ('ACTIVE','SAVED');"
(line 174)

SQL Request : Select Quantity

string $req_update = "update t_shoppingcart
set sca_quantity = sca_quantity+%d, sca_last_modified = now()
where sca_id = '%s' and sca_psl_id=%d
and sca_state in ('ACTIVE','SAVED');"
(line 147)

SQL Request : Update

string $req_update_ses_id = "update t_shoppingcart set sca_ses_id = '%s' where sca_id = '%s' and sca_state = 'SAVED';" (line 232)

SQL Request : Update session id

string $req_update_state_to_active = "update t_shoppingcart
set sca_state = 'ACTIVE', sca_id = '%s'
where sca_id = '%s' and sca_state = 'SAVED';"
(line 199)

SQL Request : Update state to active

string $req_update_state_to_lost = "update t_shoppingcart set sca_state = 'LOST' where sca_id = '%s' and sca_state in ('ACTIVE','SAVED');" (line 225)

SQL Request : Update state to lost

string $req_update_state_to_saved = "update t_shoppingcart
set sca_state = 'SAVED', sca_id = '%s'
where sca_id = '%s' and sca_state = 'ACTIVE';"
(line 190)

SQL Request : Update state to saved

string $req_update_state_to_valid = "update t_shoppingcart
set sca_state = 'VALID'
where sca_id = '%s' and sca_state = 'ACTIVE';"
(line 207)

SQL Request : Update state to valid

string $req_update_state_to_valid_or_saved = "update t_shoppingcart
set sca_state = 'VALID'
where sca_id = '%s' and sca_state in ('ACTIVE', 'SAVED');"
(line 215)

SQL Request : Update state to valid or save

string $req_update_to_new_value = "update t_shoppingcart
set sca_pma_title = '%s'
,sca_psl_tax_included_price=%f
,sca_psl_original_tax_price=%f
,sca_psl_reference='%s'
,sca_psl_weight=%f
,sca_tty_value=%f
,sca_attribut_string='%s'
,sca_pma_duration=%d,
sca_pma_start_period='%s',
sca_pma_end_period='%s'
where sca_psl_id = %d and sca_pma_id=%d and sca_id='%s';"
(line 302)

SQL Request : Update to new value

Inherited Variables

Inherited from ObjectCached

ObjectCached::$m_array_already_loader
Methods
Constructor TShoppingCartFo (line 334)

Constructor, init the requests and objects

TShoppingCartFo TShoppingCartFo ()
addProduct (line 1701)

Add a product

  • return: TRUE on error
bool addProduct (integer $pm_id,  &$ps_id, integer $quantity, [bool $is_from_full_shopping_cart = false], integer $ps_id)
  • integer $pm_id
  • integer $ps_id
  • integer $quantity
  • bool $is_from_full_shopping_cart
  • &$ps_id
delete (line 913)

Delete

  • return: TRUE on error
bool delete (string $p_id)
  • string $p_id
deleteForCustomerDelete (line 1672)

delete for customer delete

  • return: TRUE on error
bool deleteForCustomerDelete (string $p_cus_id)
  • string $p_cus_id
deleteProduct (line 703)

Delte product

  • return: TRUE on error
bool deleteProduct (integer $p_psl_id)
  • integer $p_psl_id
exist (line 1163)

Test if exist

  • return: TRUE on error
bool exist (string $p_session_id,  &$r_result_bool, bool $r_result_bool)
  • string $p_session_id
  • bool $r_result_bool
  • &$r_result_bool
getCountItemInShoppingCart (line 1212)

Retrieve number of item in shopping cart

  • return: TRUE on error
bool getCountItemInShoppingCart ( &$r_result, array $r_result)
  • array $r_result
  • &$r_result
getDeliveryCosts (line 601)

Will determinate delivery cost()

  • return: TRUE on error
bool getDeliveryCosts (float $p_price, string $p_cou_name,  &$r_array_delivery_costs, array $r_array_delivery_costs)
  • float $p_price
  • string $p_cou_name
  • array $r_array_delivery_costs
  • &$r_array_delivery_costs
getDiscountTicketStructure (line 1805)

Return a shopping cart entry with a ticket discount

  • return: TRUE on error
bool getDiscountTicketStructure (string $p_pmo_title, string $p_discount_value,  &$r_result, array $r_result)
  • string $p_pmo_title
  • string $p_discount_value
  • array $r_result
  • &$r_result
getForLittle (line 1361)

Get for litlle shoppingcart

  • return: TRUE on error
bool getForLittle ( &$r_infos,  &$r_infos_for_floating_window, [integer $p_pm_id = 0], [integer $p_ps_id = 0], array $r_infos, array $r_infos_for_floating_window)
  • array $r_infos
  • array $r_infos_for_floating_window
  • integer $p_pm_id
  • integer $p_ps_id
  • &$r_infos
  • &$r_infos_for_floating_window
getList (line 1262)

Get list

  • return: TRUE on error
bool getList ( &$r_array_products,  &$r_total_price,  &$r_total_price_without_discount,  &$r_array_for_deliverycosts, array $r_array_products, float $r_total_price, float $r_total_price_without_discount, array $r_array_for_deliverycosts)
  • array $r_array_products
  • float $r_total_price
  • float $r_total_price_without_discount
  • array $r_array_for_deliverycosts
  • &$r_array_products
  • &$r_total_price
  • &$r_total_price_without_discount
  • &$r_array_for_deliverycosts
getNewUid (line 391)

Get new unique id

string getNewUid ()
getSavedCountry (line 1659)

Get saved country

void getSavedCountry ( &$r_country_name, [string $p_default = ""], string $r_country_name)
  • string $r_country_name
  • string $p_default
  • &$r_country_name
getUidPrefix (line 382)

Get uid prefis

string getUidPrefix ()
isNotValidQuantity (line 358)

Parameter Integrity checker

  • return: TRUE if not valid
  • access: private
bool isNotValidQuantity (string $p_value)
  • string $p_value
isSavedState (line 776)

Current shopping carte is saved state

bool isSavedState ()
linkToCurrentSession (line 843)

Link To current session

  • return: TRUE on error
bool linkToCurrentSession ()
reNew (line 1484)

Re new : Update a shopping cart with new prices

cette fonction permet de remettre au gout du jour un panier les nouveaux prix et autres

void reNew ( &$r_change_made, bool $r_change_made)
  • bool $r_change_made
  • &$r_change_made
setSavedCountry (line 1649)

Set cookie to preferred country

void setSavedCountry (string $country_name)
  • string $country_name
timeToLiveInDay (line 369)

Time to live in day for the saved shopping cart

integer timeToLiveInDay ()
toActiveState (line 805)

Set current shopping cart to active state

  • return: TRUE on error
bool toActiveState ()
toLostState (line 937)

Set current shopping cart to lost state

void toLostState ()
toSavedState (line 868)

Set current shopping cart to saved state

  • return: TRUE on error
bool toSavedState ()
toValidState (line 988)

Set current shopping cart to valid state

  • return: TRUE on error
bool toValidState ([bool $p_if_is_saved_also = false])
  • bool $p_if_is_saved_also
updateToNewIfNecessary (line 1526)

Update to new if necessary

  • return: TRUE on error
bool updateToNewIfNecessary (integer $p_pma_id, integer $p_psl_id, string $p_old_pma_title, float $p_old_psl_tax_included_price, string $p_old_psl_reference, float $p_old_psl_weight, float $p_old_tty_value,  &$r_there_is_a_change_made, bool $r_there_is_a_change_made)
  • integer $p_pma_id
  • integer $p_psl_id
  • string $p_old_pma_title
  • float $p_old_psl_tax_included_price
  • string $p_old_psl_reference
  • float $p_old_psl_weight
  • float $p_old_tty_value
  • bool $r_there_is_a_change_made
  • &$r_there_is_a_change_made
xAdd (line 407)

Add a product (becarefull, a quantity to 0 delete the product)

  • return: TRUE on error
  • access: private
bool xAdd (integer $p_pma_id,  &$p_psl_id, integer $p_quantity,  &$r_product_modified,  &$r_product_added, integer $p_psl_id, array $r_product_modified, array $r_product_added)
  • integer $p_pma_id
  • integer $p_psl_id
  • integer $p_quantity
  • array $r_product_modified
  • array $r_product_added
  • &$p_psl_id
  • &$r_product_modified
  • &$r_product_added
xCleanDelete (line 752)

Clean delete

  • return: TRUE on error
  • access: private
bool xCleanDelete ()
xGetDeliveryCostsByCountryName (line 635)

Determinate delivery cost by country name and weight

  • return: TRUE on error
  • access: private
bool xGetDeliveryCostsByCountryName (string $p_type_value, float $p_price, string $p_cou_name,  &$r_array_delivery_costs, array $r_array_delivery_costs)
  • string $p_type_value
  • float $p_price
  • string $p_cou_name
  • array $r_array_delivery_costs
  • &$r_array_delivery_costs
xGetDeliveryCostsByPrice (line 682)

Determine delivery cost according to price

  • return: TRUE on error
bool xGetDeliveryCostsByPrice (float $p_price,  &$r_array_delivery_costs, array $r_array_delivery_costs)
  • float $p_price
  • array $r_array_delivery_costs
  • &$r_array_delivery_costs
xGetQuantity (line 520)

get quantity

  • return: TRUE on error
  • access: private
bool xGetQuantity (string $p_id, integer $p_psl_id,  &$r_quantity, integer $r_quantity)
  • string $p_id
  • integer $p_psl_id
  • integer $r_quantity
  • &$r_quantity
xInsert (line 1019)

Insert

  • return: TRUE on error
  • access: private
bool xInsert (integer $p_pma_id, integer $p_psl_id, integer $p_quantity)
  • integer $p_pma_id
  • integer $p_psl_id
  • integer $p_quantity
xIsAlreadyInserted (line 1115)

Is already inserted

  • return: TRUE on error
  • access: private
bool xIsAlreadyInserted (integer $p_psl_id,  &$r_result_bool, [string $p_state = "ACTIVE&SAVED"], bool $r_result_bool)
  • integer $p_psl_id
  • bool $r_result_bool
  • string $p_state
  • &$r_result_bool
xShoppingCartExist (line 1175)

Shopping cart exist

  • return: TRUE on error
  • access: private
bool xShoppingCartExist (string $p_session_id,  &$r_result_bool, bool $r_result_bool)
  • string $p_session_id
  • bool $r_result_bool
  • &$r_result_bool
xToLostState (line 951)

To lost state

  • return: TRUE on error
  • access: private
bool xToLostState (string $p_id)
  • string $p_id
xUpdate (line 562)

Update

  • return: TRUE on error
  • access: private
bool xUpdate (string $p_id, integer $p_psl_id, integer $p_quantity)
  • string $p_id
  • integer $p_psl_id
  • integer $p_quantity

Inherited Methods

Inherited From ObjectCached

 ObjectCached::xClearRemember()
 ObjectCached::xClearRememberAll()
 ObjectCached::xIsRemembered()
 ObjectCached::xRemember()

Documentation generated on Tue, 25 Mar 2008 15:37:23 +0100 by phpDocumentor 1.3.2