\Order
Order objects track all the details of an order and if they were completed or not.
Makes use of permissions provider to lock out users who have not got the
relevent COMMERCE permissions for:
VIEW
EDIT
DELETE
You can define an order prefix by using the "order_prefix" config
variable
Any user can create an order (this allows us to support "guest" users).
- Author: ilateral (http://www.ilateral.co.uk)
Synopsis
class Order
extends DataObject
implements
PermissionProvider
{
- // members
- private static string $order_prefix = "";
- private static array $statuses = ;
- private static array $outstanding_statuses = ;
- private static array $historic_statuses = ;
- private static array $actions = ;
- private static array $editable_statuses = ;
- private static string $default_status = "incomplete";
- private static string $completion_status = "paid";
- private static string $incomplete_status = "incomplete";
- private static string $default_action = "post";
- private static string $existing_customer_class = "Member";
- private static $existing_customer_fields;
- private static array $existing_customer_map = ;
- private static array $db = ;
- private static array $has_one = ;
- private static array $has_many = ;
- private static array $casting = ;
- private static array $defaults = ;
- private static array $summary_fields = ;
- private static array $extensions = ;
- private static string $default_sort = "Created DESC";
- // methods
- public void QuoteLink()
- public void InvoiceLink()
- public void populateDefaults()
- public void getCMSFields()
- public void getBillingAddress()
- public String getCountryFull()
- public void getDeliveryAddress()
- public String getDeliveryCountryFull()
- public Order markComplete()
- public void hasDiscount()
- public Decimal getSubTotal()
- public Decimal getPostage()
- public Decimal getTaxTotal()
- public Decimal getTotal()
- public string getItemSummary()
- public string getItemSummaryHTML()
- protected void generate_order_number()
- protected void generate_random_string()
- protected void validAccessKey()
- protected void validOrderNumber()
- public DataObject duplicate()
- public void onBeforeDelete()
- public void onBeforeWrite()
- public void onAfterWrite()
- public void providePermissions()
- public Boolean canView()
- public Boolean canCreate()
- public Boolean canEdit()
- public Boolean canChangeStatus()
- public Boolean canDelete()
Hierarchy
Extends
- DataObject
Implements
- PermissionProvider
Members
private
- $actions
—
array
Actions on an order are to determine what will happen on completion (the defaults are post or collect). - $casting
- $completion_status
—
string
The status which an order is considered "complete" (meaning ready for processing, dispatch, etc). - $db
- $default_action
—
string
Set the default action on our order. If we were using this module for a more POS type solution, we would probably change this to collect. - $default_sort
- $default_status
—
string
Set the default status for a new order, if this is set to null or blank, it will not be used. - $defaults
- $editable_statuses
—
array
List of statuses that allow editing of an order. We can use this to fix certain orders in the CMS -
$existing_customer_class
This is the class that can be auto mapped to an order/estimate. -
$existing_customer_fields
The list of fields that will show in the existing customer gridfield. - $existing_customer_map
—
array
Select the fields that will be copied from the source object to our order. We add these here so they can be easily altered through config. - $extensions
- $has_many
- $has_one
- $historic_statuses
—
array
What statuses does an order need to be marked as "historic". - $incomplete_status
—
string
The status which an order has not been completed (meaning it is not ready for processing, dispatch, etc). - $order_prefix
—
string
Add a string to the start of an order number (can be useful for exporting orders). - $outstanding_statuses
—
array
What statuses does an order need to be marked as "outstanding". - $statuses
—
array
List of possible statuses this order can have. Rather than using an enum, we load this as a config variable that can be changed more freely. - $summary_fields
Methods
protected
public
- InvoiceLink()
- QuoteLink()
- canChangeStatus() — Only users with EDIT admin rights can view an order
- canCreate() — Anyone can create orders, even guest users
- canDelete() — No one should be able to delete an order once it has been created
- canEdit() — Only users with EDIT admin rights can view an order
- canView() — Only order creators or users with VIEW admin rights can view
- duplicate() — Create a duplicate of this order/estimate as well as duplicating associated items
- getBillingAddress()
- getCMSFields()
- getCountryFull() — Get the rendered name of the billing country, based on the local
- getDeliveryAddress()
- getDeliveryCountryFull() — Get the rendered name of the delivery country, based on the local
- getItemSummary() — Return a list string summarising each item in this order
- getItemSummaryHTML() — Return a list string summarising each item in this order
- getPostage() — Get the postage cost for this order
- getSubTotal() — Total values of items in this order (without any tax)
- getTaxTotal() — Total values of items in this order
- getTotal() — Total of order including postage
- hasDiscount()
- markComplete() — Mark this order as "complete" which generally is intended to mean "paid for, ready for processing".
- onAfterWrite() — API Callback after this object is written to the DB
- onBeforeDelete() — API Callback before this object is removed from to the DB
- onBeforeWrite() — API Callback after this object is written to the DB
- populateDefaults()
- providePermissions()