\Order
Order, created as soon as a user adds a {@link Product} to their cart, the cart is actually an Order with status of 'Cart'. Has many {@link Item}s and can have {@link Modification}s which might represent a {@link Modifier} like shipping, tax, coupon codes.
Synopsis
class Order
extends DataObject
implements
PermissionProvider
{
- // constants
- const STATUS_PENDING = 'Pending';
- const STATUS_PROCESSING = 'Processing';
- const STATUS_DISPATCHED = 'Dispatched';
- // members
- private static Array $db = ;
- private static Array $has_one = ;
- private static array $has_many = ;
- private static Array $summary_fields = ;
- private static Array $searchable_fields = ;
- private static String $default_sort = 'ID DESC';
- public static Int $first_id = NULL;
- // methods
- public void augmentSQL()
- public void Total()
- public Price TotalPrice()
- public void SubTotal()
- public Price SubTotalPrice()
- public void CartTotalPrice()
- public void providePermissions()
- public void canView()
- public Boolean canEdit()
- public Boolean canCreate()
- public Boolean canDelete()
- public void delete()
- public FieldSet scaffoldSearchFields()
- public ShopSearchContext getDefaultSearchContext()
- public void onBeforeWrite()
- public void onAfterWrite()
- public void onBeforePayment()
- public void onAfterPayment()
- public void getCMSFields()
- public FieldList getCMSActions()
- public String SummaryOfTotal()
- public String Link()
- public ArrayList Payments()
- public Money TotalOutstanding()
- public Price TotalPaid()
- public Boolean getPaid()
- public void addItem()
- public DataObject findIdenticalItem()
- public void updateTotal()
- public ArrayList Products()
- public String SummaryOfPaymentStatus()
- public void updateModifications()
- public ValidationResult validateForCart()
- public void validate()
- public static Void delete_abandoned()
- public DataList SubTotalModifications()
- public DataList TotalModifications()
- public void CustomerUpdates()
Hierarchy
Extends
- DataObject
Implements
- PermissionProvider
Tasks
Line | Task |
---|---|
61 | Multi currency |
84 | Multi currency |
506 | Multi currency |
684 | change this so doesn't write() in here |
Constants
Name | Value |
---|---|
STATUS_PENDING | 'Pending' |
STATUS_PROCESSING | 'Processing' |
STATUS_DISPATCHED | 'Dispatched' |
Members
private
- $db
—
Array
DB fields for Order, such as Stauts, Payment Status etc. - $default_sort
—
String
The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. - $has_many
- $has_one
—
Array
Relations for this Order - $searchable_fields
—
Array
Searchable fields with search filters - $summary_fields
—
Array
Summary fields for displaying Orders in the admin area
public
- $first_id
—
Int
The starting number for Order IDs. If none set starts at 1.
Methods
public
- CartTotalPrice()
- CustomerUpdates()
- Link() — Generate the URL for viewing this order on the frontend
- Payments() — Helper to get {@link Payment}s that are made against this Order
- Products() — Retreive products for this order from the order {@link Item}s.
- SubTotal()
- SubTotalModifications() — Get modifications that apply changes to the Order sub total.
- SubTotalPrice() — Display price, can decorate for multiple currency etc.
- SummaryOfPaymentStatus() — Helper to summarize payment status for an order.
- SummaryOfTotal() — Helper to get a nicely formatted total of the order
- Total()
- TotalModifications() — Get modifications that apply changes to the Order total (not the order sub total).
- TotalOutstanding() — Calculate the total outstanding for this order that remains to be paid, all payments except 'Failure', 'Pending' and 'Incomplete' payments are considered - so only 'Success' payments.
- TotalPaid() — Calculate the total paid for this order, only 'Success' payments are considered.
- TotalPrice() — Display price, can decorate for multiple currency etc.
- addItem() — Add an item to the order representing the product, if an item for this product exists increase the quantity. Update the Order total afterward.
- augmentSQL() — Provides all Member properties, for use in summary_fields etc
- canCreate() — Prevent orders from being created in the CMS
- canDelete() — Prevent orders from being deleted in the CMS
- canEdit() — Prevent orders from being edited in the CMS
- canView()
- delete() — Clean up Order Items (ItemOptions by extension) and Modifications.
- 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.
- findIdenticalItem() — 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.
- getCMSActions() — Set custom CMS actions which call OrderAdmin_RecordController actions of the same name
- getCMSFields() — Set CMS fields for viewing this Order in the CMS Cannot change status of an order in the CMS
- getDefaultSearchContext() — Get a new search context for filtering the search results in OrderAdmin
- getPaid() — If the order has been totally paid.
- onAfterPayment() — Processed if payment is successfully written, send a receipt to the customer and notification to the admin
- onAfterWrite()
- onBeforePayment()
- onBeforeWrite() — Set the LastActive time when {@link Order} first created.
- providePermissions()
- scaffoldSearchFields() — Filters for order admin area search.
- updateModifications() — Save modifiers for this Order at the checkout process.
- updateTotal() — Go through items and modifiers and update cart total
- validate() — By default Orders are always valid
- validateForCart() — Valdiate this Order for use in Validators at checkout. Makes sure Items exist and each Item is valid.