VbzCart/docs/tables/shop cart: Difference between revisions

From Woozle Writes Code
< VbzCart‎ | docs‎ | tables
Jump to navigation Jump to search
imported>Woozle
(+ShipZone field)
m (Woozle moved page VbzCart/VbzCart/tables/shop cart to VbzCart/docs/tables/shop cart without leaving a redirect: part 4/5)
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
<hide>
[[thing type::table design]]
[[project::VbzCart]]
[[subsystem::shopping]]
[[status::active]]
</hide>
==About==
==About==
* '''Purpose''': Shopping cart data is kept separate from order data because we end up with a lot of carts that never become orders; eventually they get cleaned out. Order data may eventually get cleaned out too, but with different criteria; for now, we are keeping order data indefinitely.
* '''Purpose''': Shopping cart data is kept separate from order data because we end up with a lot of carts that never become orders; eventually they get cleaned out. Order data may eventually get cleaned out too, but with different criteria; for now, we are keeping order data indefinitely.
* '''Relations''':
* '''Relations''':
** each {{vbzcart|table|shop_session}} has one or more {{vbzcart|table|shop_cart}}s
*** a single session can discard one cart and create another
*** sessions only use carts they create, never reusing one created by another session
** each {{vbzcart|table|shop_cart}} exactly one {{vbzcart|table|shop_session}}
** each {{vbzcart|table|shop_cart}} has zero or one {{vbzcart|table|core_orders}} record (it's only zero until the order is placed)
** each {{vbzcart|table|shop_cart}} has zero or one {{vbzcart|table|core_orders}} record (it's only zero until the order is placed)
** each {{vbzcart|table|core_orders}} record has exactly one {{vbzcart|table|shop_cart}}
** each {{vbzcart|table|core_orders}} record has exactly one {{vbzcart|table|shop_cart}}
** each {{vbzcart|table|shop_cart}} has zero or one {{vbzcart|table|core_custs}} record (it's only zero until the order is placed, but ID_Cust isn't necessarily filled in when this happens)
** each {{vbzcart|table|shop_cart}} has zero or one {{vbzcart|table|core_custs}} record (it's only zero until the order is placed, but ID_Cust isn't necessarily filled in when this happens)
** each {{vbzcart|table|core_custs}} record has one or more {{vbzcart|table|shop_cart}}s and one or more {{vbzcart|table|core_orders}}
** each {{vbzcart|table|core_custs}} record has one or more {{vbzcart|table|shop_cart}}s and one or more {{vbzcart|table|core_orders}}
* '''Fields''':
* '''Rules''':
** '''ID_Cust''' is for future use when customers can log in to retrieve their personal data before checking out
** Each {{vbzcart|table|user_session}} has zero or one {{vbzcart|table|shop_cart}}s (currently stored in custom ID_Cart field, but will eventually be Stashed)
** '''ID_Session''' is the ID of the session ({{vbzcart|table|shop_session}}) where the cart was created & accessed
*** A single session may discard one cart and start a new one.
*** Different sessions cannot access the same cart. (Is there a good reason for this, or does it just ''sound'' good?)
*** Sessions only use carts they create, never reusing one created by another session (but see Security, below)
** '''ShipZone''' represents the string-code for the shipping zone, which is used to determine shipping cost
*** Each session knows only the cart it is currently using.
*** currently, this is hard-coded to apply a different multiplier for each zone - {US shipping cost}x{zone multiplier}
 
* '''History''':
===Fields===
** '''2009-06-16''' Changing names to singular (tables not in use yet, so this is the time to do it)
* '''ID_Cust''' is for future use when customers can log in to retrieve their personal data before checking out
** '''2009-07-10''' removing ID_Session: each session ties to a cart, not vice-versa
* '''ID_Sess''' is the ID of the session ({{vbzcart|table|shop_session}}) where the cart was created & accessed
** '''2009-07-16''' added ShipZone field
** Different sessions cannot access the same cart. (Is there a good reason for this, or does it just ''sound'' good?)
** One session may have multiple carts.
* '''ShipZone''' represents the string-code for the shipping zone, which is used to determine shipping cost
** currently, this is hard-coded to apply a different multiplier for each zone - {US shipping cost}x{zone multiplier}
* '''FieldData''' is a [http://php.net/serialize serialize]d array of the data formerly stored in {{l/vc/table|shop_cart_data}}. This is an experimental field which will become permanent if it works out.
===History===
* '''2009-06-16''' Changing names to singular (tables not in use yet, so this is the time to do it)
* '''2009-07-10''' removing '''ID_Session''': each session ties to a cart, not vice-versa
** ...except that we still have ID_Sess
* '''2009-07-16''' added '''ShipZone''' field
* '''2009-07-18''' added '''ID_Sess''' field (field documentation seems to think it was already there...)
* '''2011-03-27''' added '''WhenVoided''' field so we never zero out ID_Cart
* '''2016-03-07''' added '''FieldData''' field
* '''2016-06-23''' renaming '''WhenOrdered''' to '''WhenPorted''': when Cart record was used to create an Order (''not'' when the Order was formally submitted)
* '''2016-06-24''' removing '''WhenViewed''', since code never sets it (NULL in all existing records) and the purpose for which it was probably intended (diagnostic) is better served by the event log.
==SQL==
==SQL==
<section begin=sql /><mysql>DROP TABLE IF EXISTS `shop_cart`;
<source lang=mysql>CREATE TABLE `shop_cart` (
CREATE TABLE `shop_cart` (
   `ID`          INT            NOT NULL AUTO_INCREMENT,
   `ID`          INT            NOT NULL AUTO_INCREMENT,
   `WhenCreated` DATETIME      NOT NULL COMMENT "when the cart was first created",
   `WhenCreated` DATETIME      NOT NULL COMMENT "when the cart was first created",
  `WhenViewed`  DATETIME  DEFAULT NULL COMMENT "when the cart's contents were last displayed by the customer",
   `WhenUpdated` DATETIME  DEFAULT NULL COMMENT "when the cart's contents were last changed",
   `WhenUpdated` DATETIME  DEFAULT NULL COMMENT "when the cart's contents were last changed",
   `WhenOrdered` DATETIME  DEFAULT NULL COMMENT "when the cart's contents were transferred to an order",
   `WhenPorted` DATETIME  DEFAULT NULL COMMENT "when the cart's contents were transferred to an order",
  `WhenVoided`  DATETIME  DEFAULT NULL COMMENT "when this cart was discarded",
  `ID_Sess`    INT            NOT NULL COMMENT "shop_session.ID which used this cart",
   `ID_Order`    INT        DEFAULT NULL COMMENT "core_orders.ID of order into which cart was transferred",
   `ID_Order`    INT        DEFAULT NULL COMMENT "core_orders.ID of order into which cart was transferred",
   `ID_Cust`    INT        DEFAULT NULL COMMENT "core_custs.ID of customer for this order",
   `ID_Cust`    INT        DEFAULT NULL COMMENT "core_custs.ID of customer for this order",
   `ShipZone`    VARCHAR(3) DEFAULT NULL COMMENT "shipping cost zone",
   `ShipZone`    VARCHAR(3) DEFAULT NULL COMMENT "shipping cost zone",
  `FieldData`  TEXT      DEFAULT NULL COMMENT "other values associated with the cart (serialized)",
   PRIMARY KEY(`ID`)
   PRIMARY KEY(`ID`)
  ) ENGINE = MYISAM;</mysql>
  ) ENGINE = INNODB;</source>
<section end=sql />

Latest revision as of 01:57, 25 February 2024

<hide> thing type::table design [[project::VbzCart]] subsystem::shopping status::active </hide>

About

  • Purpose: Shopping cart data is kept separate from order data because we end up with a lot of carts that never become orders; eventually they get cleaned out. Order data may eventually get cleaned out too, but with different criteria; for now, we are keeping order data indefinitely.
  • Relations:
  • Rules:
    • Each Template:Vbzcart has zero or one Template:Vbzcarts (currently stored in custom ID_Cart field, but will eventually be Stashed)
      • A single session may discard one cart and start a new one.
      • Sessions only use carts they create, never reusing one created by another session (but see Security, below)
      • Each session knows only the cart it is currently using.

Fields

  • ID_Cust is for future use when customers can log in to retrieve their personal data before checking out
  • ID_Sess is the ID of the session (Template:Vbzcart) where the cart was created & accessed
    • Different sessions cannot access the same cart. (Is there a good reason for this, or does it just sound good?)
    • One session may have multiple carts.
  • ShipZone represents the string-code for the shipping zone, which is used to determine shipping cost
    • currently, this is hard-coded to apply a different multiplier for each zone - {US shipping cost}x{zone multiplier}
  • FieldData is a serialized array of the data formerly stored in Template:L/vc/table. This is an experimental field which will become permanent if it works out.

History

  • 2009-06-16 Changing names to singular (tables not in use yet, so this is the time to do it)
  • 2009-07-10 removing ID_Session: each session ties to a cart, not vice-versa
    • ...except that we still have ID_Sess
  • 2009-07-16 added ShipZone field
  • 2009-07-18 added ID_Sess field (field documentation seems to think it was already there...)
  • 2011-03-27 added WhenVoided field so we never zero out ID_Cart
  • 2016-03-07 added FieldData field
  • 2016-06-23 renaming WhenOrdered to WhenPorted: when Cart record was used to create an Order (not when the Order was formally submitted)
  • 2016-06-24 removing WhenViewed, since code never sets it (NULL in all existing records) and the purpose for which it was probably intended (diagnostic) is better served by the event log.

SQL

CREATE TABLE `shop_cart` (
  `ID`          INT            NOT NULL AUTO_INCREMENT,
  `WhenCreated` DATETIME       NOT NULL COMMENT "when the cart was first created",
  `WhenUpdated` DATETIME   DEFAULT NULL COMMENT "when the cart's contents were last changed",
  `WhenPorted`  DATETIME   DEFAULT NULL COMMENT "when the cart's contents were transferred to an order",
  `WhenVoided`  DATETIME   DEFAULT NULL COMMENT "when this cart was discarded",
  `ID_Sess`     INT            NOT NULL COMMENT "shop_session.ID which used this cart",
  `ID_Order`    INT        DEFAULT NULL COMMENT "core_orders.ID of order into which cart was transferred",
  `ID_Cust`     INT        DEFAULT NULL COMMENT "core_custs.ID of customer for this order",
  `ShipZone`    VARCHAR(3) DEFAULT NULL COMMENT "shipping cost zone",
  `FieldData`   TEXT       DEFAULT NULL COMMENT "other values associated with the cart (serialized)",
   PRIMARY KEY(`ID`)
 ) ENGINE = INNODB;