swipestripe
[ class tree: swipestripe ] [ index: swipestripe ] [ all elements ]

Class: Item

Source Location: /code/order/Item.php

Class Overview

DataObject
   |
   --Item

An Item for an Order.


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright (c) 2011, Frank Mullenger

Variables

Methods



Class Details

[line 11]
An Item for an Order.



Tags:

author:  Frank Mullenger <frankmullenger@gmail.com>
version:  1.0
copyright:  Copyright (c) 2011, Frank Mullenger


[ Top ]


Class Variables

static $create_table_options = array(
      'MySQLDatabase' => 'ENGINE=InnoDB'
   )

[line 59]


Type:   mixed


[ Top ]

static $db = array(
     'ObjectID' => 'Int',
     'ObjectClass' => 'Varchar',
      'ObjectVersion' => 'Int',
     'Amount' => 'Money',
     'PreviousQuantity' => 'Int',
     'Quantity' => 'Int',
     'DownloadCount' => 'Int' //If item represents a downloadable product,
   )

[line 20]

DB fields for an Item, the object this Item represents (e.g. Product has a version ID saved as well, so if price is changed or something then a record of the price at time of ordering exists and can be retrieved.



Tags:

access:  public

Type:   Array


[ Top ]

static $defaults = array(
     'PreviousQuantity' => 0,
     'Quantity' => 1,
     'DownloadCount' => 0
   )

[line 53]

Default values for this class



Tags:

access:  public

Type:   Array


[ Top ]

static $has_many = array(
     'ItemOptions' => 'ItemOption'
   )

[line 44]

Relations for this class



Tags:

access:  public

Type:   Array


[ Top ]

static $has_one = array(
      'Order' => 'Order'
   )

[line 35]

Relations for this class



Tags:

access:  public

Type:   Array


[ Top ]



Class Methods


method Object [line 69]

DataObject Object( )

Retrieve the object this item represents (e.g. Product). Uses versioning so that the product that was bought can be retrieved with all the correct details.



[ Top ]

method onAfterWrite [line 246]

void onAfterWrite( )

Update stock levels for Item.



Tags:

access:  public


[ Top ]

method onBeforeDelete [line 78]

void onBeforeDelete( )

Find item options and delete them to clean up DB.



Tags:

access:  public


[ Top ]

method onBeforeWrite [line 230]

void onBeforeWrite( )

Update the quantity of the item.

PreviousQuantity starts at 0.




[ Top ]

method Product [line 153]

Mixed Product( )

Get the product for the item



Tags:

return:  Product if it exists, otherwise null


[ Top ]

method Total [line 115]

Money Total( )

Get unit price for this item including item options price and quantity.



Tags:

return:  Item total inclusive of item options prices and quantity
access:  public


[ Top ]

method UnitPrice [line 97]

Money UnitPrice( )

Get unit price for this Item including price or any ItemOptions.



Tags:

return:  Item price inclusive of item options prices
access:  public


[ Top ]

method updateStockLevels [line 258]

void updateStockLevels( )

Update StockLevel for Product exists.



Tags:

access:  public


[ Top ]

method validate [line 180]

ValidationResult validate( )

Validate that product exists and is published, variation exists for product if necessary and quantity is greater than 0

TODO remove the check for $firstWrite when transactions are implemented




[ Top ]

method validateForCart [line 167]

ValidationResult validateForCart( )

Validate this Item to make sure it can be added to a cart.



[ Top ]

method Variation [line 135]

Mixed Variation( )

Get the variation for the item if a Variation exists in the ItemOptions This assumes only one variation per item.



Tags:

return:  Variation if it exists, otherwise null


[ Top ]


Documentation generated on Thu, 08 Mar 2012 16:47:26 +1300 by phpDocumentor 1.4.4