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

Class: Order

Source Location: /code/order/Order.php

Class Overview

DataObject
   |
   --Order

Order, created as soon as a user adds a Product to their cart, the cart is actually an Order with status of 'Cart'. Has many Items and can have Modifications which might represent a Modifier like shipping, tax, coupon codes.


Author(s):

Version:

  • 1.0

Copyright:

  • Copyright (c) 2011, Frank Mullenger

Variables

Constants

Methods



Class Details

[line 13]
Order, created as soon as a user adds a Product to their cart, the cart is actually an Order with status of 'Cart'. Has many Items and can have Modifications which might represent a Modifier like shipping, tax, coupon codes.



Tags:

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


[ Top ]


Class Variables

static $casting = array(
      'HasPayment' => 'Money'
   )

[line 159]

Castings for the searchable fields



Tags:

access:  public

Type:   Array


[ Top ]

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

[line 168]

Table type for Orders should be InnoDB to support transactions - which are not implemented yet.


Type:   Array


[ Top ]

static $db = array(
      'Status' => "Enum('Pending,Processing,Dispatched,Cancelled,Cart','Cart')",
     'PaymentStatus' => "Enum('Unpaid,Paid','Unpaid')",
     'Total' => 'Money',
     'SubTotal' => 'Money',
      'ReceiptSent' => 'Boolean',
     'NotificationSent' => 'Boolean',
     'OrderedOn' => 'SS_Datetime',
     'LastActive' => 'SS_Datetime',
     'Notes' => 'Text'
   )

[line 52]

DB fields for Order, such as Stauts, Payment Status etc.



Tags:

access:  public

Type:   Array


[ Top ]

static $defaults = array(
     'ReceiptSent' => false,
     'NotificationSent' => false
   )

[line 69]

Default values for Order



Tags:

access:  public

Type:   Array


[ Top ]

static $default_sort =  'ID DESC'

[line 179]

The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.



Tags:

access:  public

Type:   String


[ Top ]

static $has_many = array(
     'Items' => 'Item',
      'Payments' => 'Payment',
     'Modifications' => 'Modification',
     'Addresses' => 'Address'
   )

[line 88]



Tags:

access:  public

Type:   mixed


[ Top ]

static $has_one = array(
     'Member' => 'Customer'
   )

[line 79]

Relations for this Order



Tags:

access:  public

Type:   Array


[ Top ]

static $searchable_fields = array(
     'ID' => array(
         'field' => 'TextField',
         'filter' => 'PartialMatchFilter',
         'title' => 'Order Number'
      ),'Member.Surname'=>array('title'=>'Customer Surname','filter'=>'PartialMatchFilter'),'Member.Email'=>array('title'=>'Customer Email','filter'=>'PartialMatchFilter'),'HasPayment'=>array('filter'=>'PaymentSearchFilter',),'OrderedOn'=>array('filter'=>'DateRangeSearchFilter'),'Status'=>array('title'=>'Status','filter'=>'OptionSetSearchFilter',))

[line 128]

Searchable fields with search filters



Tags:

access:  public

Type:   Array


[ Top ]

static $summary_fields = array(
     'ID' => 'Order No',
      'OrderedOn' => 'Ordered On',
     //'LastActive' => 'Last Active',
      'Member.Name' => 'Customer',
      'SummaryOfTotal' => 'Total',
      'Status' => 'Status'
   )

[line 114]

Summary fields for displaying Orders in the admin area



Tags:

access:  public

Type:   Array


[ Top ]

static $table_overview_fields = array(
      'ID' => 'Order No',
      'Created' => 'Created',
      'Member.FirstName' => 'First Name',
      'Member.Surname' => 'Surname',
      'Total' => 'Total',
      'Status' => 'Status'
   )

[line 100]

Overview fields for displaying Orders in the admin area



Tags:

access:  public

Type:   Array


[ Top ]

static $timeout =  '-1 hour'

[line 45]

Life of shopping cart, how long the cart will remain after abandoned.

e.g: A cart is considered abandoned 1 hour after the last page request and will be deleted thereby releasing the stock in the cart back to the system.




Tags:

var:  Relative format for strtotime()
access:  protected

Type:   String


[ Top ]



Class Methods


static method delete_abandoned [line 864]

static Void delete_abandoned( )

Delete abandoned carts according to the Order timeout. This will release the stock in the carts back to the shop. Can be run from a cron job task, also run on Product, Cart and Checkout pages so that cron job is not necessary.



Tags:

access:  public


[ Top ]

static method get_timeout [line 853]

static String get_timeout( )

Get the order timeout, for managing stock levels.



Tags:

return:  Relative time format for strtotime()
access:  public


[ Top ]

static method set_timeout [line 844]

static void set_timeout( String $interval)

Set order timeout, how long the cart will remain after abandoned.

e.g: A cart is considered abandoned 1 hour after the last page request and will be deleted thereby releasing the stock in the cart back to the system.




Tags:

access:  public


Parameters:

String   $interval   Relative time format for strtotime()

[ Top ]

method addAddressesAtCheckout [line 653]

void addAddressesAtCheckout( Array $data)

Add addresses to this Order at the checkout.



Parameters:

Array   $data  

[ Top ]

method addItem [line 476]

void addItem( DataObject $product, [ $quantity = 1], [DataObjectSet $productOptions = null])

Add an item to the order representing the product, if an item for this product exists increase the quantity. Update the Order total afterward.



Parameters:

DataObject   $product   The product to be represented by this order item
DataObjectSet   $productOptions   The product variations to be added, usually just one
   $quantity  

[ Top ]

method addModifiersAtCheckout [line 631]

void addModifiersAtCheckout( Array $data)

Save modifiers for this Order at the checkout process.



Parameters:

Array   $data  

[ Top ]

method augmentDatabase [line 901]

void augmentDatabase( )

Testing to add auto increment to table



Tags:

deprecated:  
access:  public


[ Top ]

method BillingAddress [line 720]

Address BillingAddress( )

Retrieve the billing Address for this Order.



[ Top ]

method canCreate [line 220]

Boolean canCreate( [ $member = null])

Prevent orders from being created in the CMS



Tags:

return:  False always
access:  public


Parameters:

   $member  

[ Top ]

method canDelete [line 230]

Boolean canDelete( [ $member = null])

Prevent orders from being deleted in the CMS



Tags:

return:  False always
access:  public


Parameters:

   $member  

[ Top ]

method delete [line 795]

void delete( )

Delete this data object.

$this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted.




Tags:

access:  public
uses:  DataObjectDecorator->augmentSQL()


[ Top ]

method findIdenticalItem [line 533]

DataObject findIdenticalItem( DatObject $product, DataObjectSet $productOptions)

Find an identical item in the order/cart, item is identical if the productID, version and the options for the item are the same. Used to increase quantity of items that already exist in the cart/Order.



Parameters:

DatObject   $product  
DataObjectSet   $productOptions  

[ Top ]

method getCMSActions [line 313]

FieldSet getCMSActions( )

Set custom CMS actions which call OrderAdmin_RecordController actions of the same name



Tags:

access:  public


[ Top ]

method getCMSFields [line 240]

void getCMSFields( )

Set CMS fields for viewing this Order in the CMS Cannot change status of an order in the CMS



Tags:

access:  public


[ Top ]

method getDefaultSearchContext [line 206]

DateRangeSearchContext getDefaultSearchContext( )

Get a new date range search context for filtering the search results in OrderAdmin



Tags:

access:  public


[ Top ]

method getPaid [line 465]

Boolean getPaid( )

If the order has been totally paid.



Tags:

access:  public


[ Top ]

method Link [line 333]

String Link( )

Generate the URL for viewing this order on the frontend



Tags:

return:  URL for viewing this order


[ Top ]

method onAfterPayment [line 401]

void onAfterPayment( )

Processed if payment is successfully written, send a receipt to the customer TODO move sending receipts to CheckoutPage::ProcessOrder()



[ Top ]

method onBeforeWrite [line 891]

void onBeforeWrite( )

Set the LastActive time when Order first created.

(non-PHPdoc)




[ Top ]

method Payments [line 344]

DataObjectSet Payments( )

Helper to get Payments that are made against this Order



Tags:

return:  Set of Payment objects


[ Top ]

method Products [line 593]

DataObjectSet Products( )

Retreive products for this order from the order Items.



Tags:

return:  Set of Products


[ Top ]

method scaffoldSearchFields [line 187]

FieldSet scaffoldSearchFields( )

Filters for order admin area search.



[ Top ]

method sendNotification [line 430]

void sendNotification( )

Send an order notification to admin if one has not already been sent.



Tags:

access:  public


[ Top ]

method sendReceipt [line 416]

void sendReceipt( )

Send a receipt if one has not already been sent.



Tags:

access:  public


[ Top ]

method ShippingAddress [line 736]

Address ShippingAddress( )

Retrieve the shipping Address for this Order.



[ Top ]

method SummaryOfPaymentStatus [line 607]

String SummaryOfPaymentStatus( )

Helper to summarize payment status for an order.



Tags:

return:  List of payments and their status


[ Top ]

method SummaryOfTotal [line 323]

String SummaryOfTotal( )

Helper to get a nicely formatted total of the order



Tags:

return:  Order total formatted with Nice()


[ Top ]

method TotalOutstanding [line 354]

Money TotalOutstanding( )

Calculate the total outstanding for this order that remains to be paid, all payments except 'Failure' payments are considered



Tags:

return:  With value and currency of total outstanding


[ Top ]

method TotalPaid [line 379]

Money TotalPaid( )

Calculate the total paid for this order, only 'Success' payments are considered.



Tags:

return:  With value and currency of total paid


[ Top ]

method updatePaymentStatus [line 446]

void updatePaymentStatus( )

Update the order payment status after Payment is made.



Tags:

access:  public


[ Top ]

method updateTotal [line 565]

void updateTotal( )

Go through items and modifiers and update cart total

Had to use DataObject::get() to retrieve Items because $this->Items() was not returning any items after first call to $this->addItem().




Tags:

access:  public


[ Top ]

method validate [line 785]

void validate( )

By default Orders are always valid



[ Top ]

method validateForCart [line 753]

ValidationResult validateForCart( )

Valdiate this Order for use in Validators at checkout. Makes sure Items exist and each Item is valid.



[ Top ]


Class Constants

STATUS_DISPATCHED =  'Dispatched'

[line 34]

Order status once Order has been sent


[ Top ]

STATUS_PENDING =  'Pending'

[line 20]

Order status once Order has been made, waiting for payment to clear/be approved


[ Top ]

STATUS_PROCESSING =  'Processing'

[line 27]

Order status once payment approved, order being processed before being dispatched


[ Top ]



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