Sunnysideup\Ecommerce\Model\Order
The order class is a databound object for handling Orders within SilverStripe.
Synopsis
class Order
extends DataObject
implements
EditableEcommerceObject
{
- // members
- protected $totalItems;
- protected $totalItemsTimesQuantity;
- protected static $_modifier_form_cache;
- protected array $fieldsAndTabsToBeRemoved = ;
- protected bool $_isSubmittedTempVar = 1;
- protected static array[Order] $order_cache = ;
- private static array $api_access = ;
- private static array $modifiers = ;
- private static integer $minutes_an_order_can_be_viewed_without_logging_in = 4320;
- private static float $maximum_ignorable_sales_payments_difference = 0.01;
- private static integer $order_id_start_number = 0;
- private static string $template_id_prefix = '';
- private static array $ajax_subtotal_format = ;
- private static array $ajax_total_format = ;
- private static string $date_format_for_title = 'd MMM Y, HH:mm ';
- private static bool $include_customer_name_in_title = true;
- private static string $table_name = 'Order';
- private static array $db = ;
- private static array $has_one = ;
- private static array $has_many = ;
- private static array $indexes = ;
- private static array $default_sort = ;
- private static array $casting = ;
- private static string $singular_name = 'Order';
- private static string $plural_name = 'Orders';
- private static string $description = "A collection of items that together make up the 'Order'. An order can be placed.";
- private static array $_needs_recalculating = ;
- private static array $summary_fields = ;
- private static array $csv_export_fields = ;
- private static array $searchable_fields = ;
- private static array $_try_to_finalise_order_is_running = ;
- // methods
- public static void set_order_cached()
- public static void get_order_cached()
- public array getExportFields()
- public void i18n_singular_name()
- public void i18n_plural_name()
- public static void set_needs_recalculating()
- public static void get_needs_recalculating()
- public void getModifierForms()
- public static DataList get_order_status_options()
- public static null|Order get_by_id_if_can_view()
- public static DataList get_datalist_of_orders_with_submit_record()
- public static void get_datalist_of_orders_with_joined_submission_record()
- public FieldList scaffoldSearchFields()
- public string CMSEditLink()
- public void getCMSFields()
- public GridField getModifierTableField()
- public GridField getOrderStatusLogsTableField()
- public GridField getOrderStatusLogsTableFieldEditable()
- public GridField getEmailsTableField()
- public OrderStepField OrderStepField()
- public DataObject init()
- public void tryToFinaliseOrder()
- public int doNextStatus()
- public OrderStatusLogCancel Cancel()
- public bool Archive()
- public DataObject MyStep()
- public OrderStatusLog RelevantLogEntry()
- public OrderStep CurrentStepVisibleToCustomer()
- public bool IsFirstStep()
- public bool IsInCart()
- public bool IsPastCart()
- public bool IsUncomplete()
- public bool IsProcessing()
- public bool IsCompleted()
- public bool IsPaid()
- public string IsPaidNice()
- public void getIsPaidNice()
- public bool PaymentIsPending()
- public DataList RelevantPayments()
- public bool IsCancelled()
- public void getIsCancelled()
- public string IsCancelledNice()
- public void getIsCancelledNice()
- public bool IsCustomerCancelled()
- public bool IsAdminCancelled()
- public bool ShopClosed()
- public Member CreateOrReturnExistingMember()
- public void CreateOrReturnExistingAddress()
- public void SetCountryFields()
- public void SetRegionFields()
- public void UpdateCurrency()
- public void SetCurrency()
- public bool sendEmail()
- public bool sendAdminNotification()
- public string renderOrderInEmailFormat()
- public ArrayList getOrderAttributesByType()
- public DataList Items()
- public DataList OrderItems()
- public ArrayList Buyables()
- public DataList OrderModifiers()
- public DataList Modifiers()
- public void calculateOrderAttributes()
- public float ModifiersSubTotal()
- public null|OrderModifier RetrieveModifier()
- public bool canCreate()
- public bool canView()
- public bool canOverridecanView()
- public bool IsInSession()
- public string LessSecureSessionID()
- public void canViewAdminStuff()
- public bool canEdit()
- public void canCheckout()
- public bool canSubmit()
- public bool canPay()
- public bool canCancel()
- public bool canDelete()
- public ArrayList CanViewOrderStatusLogs()
- public ArrayList CustomerViewableOrderStatusLogs()
- public string OrderEmail()
- public void getOrderEmail()
- public bool HasPrintOrEmailLink()
- public string EmailLink()
- public void getEmailLink()
- public string PrintLink()
- public void getPrintLink()
- public string PackingSlipLink()
- public void getPackingSlipLink()
- public string RetrieveLink()
- public void getRetrieveLink()
- public void ShareLink()
- public void getShareLink()
- public string FeedbackLink()
- public null|string getFeedbackLink()
- public string DeleteLink()
- public void getDeleteLink()
- public string CopyOrderLink()
- public void getCopyOrderLink()
- public string Title()
- public void getTitle()
- public void OrderItemsSummaryNice()
- public void getOrderItemsSummaryNice()
- public void OrderItemsSummaryAsHTML()
- public float SubTotal()
- public void getSubTotal()
- public DBCurrency SubTotalAsCurrencyObject()
- public DBMoney SubTotalAsMoney()
- public void getSubTotalAsMoney()
- public DBCurrency ModifiersSubTotalAsCurrencyObject()
- public DBMoney ModifiersSubTotalAsMoneyObject()
- public float Total()
- public void getTotal()
- public DBCurrency TotalAsCurrencyObject()
- public DBMoney TotalAsMoney()
- public void getTotalAsMoney()
- public float TotalOutstanding()
- public void getTotalOutstanding()
- public DBCurrency TotalOutstandingAsCurrencyObject()
- public DBMoney TotalOutstandingAsMoney()
- public void getTotalOutstandingAsMoney()
- public float TotalPaid()
- public void getTotalPaid()
- public DBCurrency TotalPaidAsCurrencyObject()
- public DBMoney TotalPaidAsMoney()
- public void getTotalPaidAsMoney()
- public void TotalItems()
- public void getTotalItems()
- public bool MoreThanOneItemInCart()
- public float TotalItemsTimesQuantity()
- public void getTotalItemsTimesQuantity()
- public string Country()
- public string getCountry()
- public bool IsSeparateShippingAddress()
- public string FullNameCountry()
- public string getFullNameCountry()
- public string ExpectedCountryName()
- public string getExpectedCountryName()
- public string FixedCountry()
- public void getFixedCountry()
- public DataObject Region()
- public void getRegion()
- public bool HasAlternativeCurrency()
- public void getHasAlternativeCurrency()
- public void EnsureCorrectExchangeRate()
- public bool IsSubmitted()
- public bool getIsSubmitted()
- public bool IsArchived()
- public OrderStatusLog SubmissionLog()
- public DBDatetime OrderDate()
- public int SecondsSinceBeingSubmitted()
- public ArrayList SubmitErrors()
- public string CustomerStatus()
- public void getCustomerStatus()
- public bool CanHaveShippingAddress()
- public void getCanHaveShippingAddress()
- public null|CartPage DisplayPage()
- public string Link()
- public string CheckoutLink()
- public string ConvertToHTML()
- public string ConvertToString()
- public string ConvertToJSON()
- public EcommerceConfigAjax AJAXDefinitions()
- public array updateForAjax()
- public float SubTotalCartValue()
- public string debug()
- public void getCustomer()
- protected void onBeforeWrite()
- protected void onAfterWrite()
- protected void onBeforeDelete()
- protected GridField getOrderItemsField()
- protected GridField getBillingAddressField()
- protected GridField getShippingAddressField()
- protected GridField getOrderStatusLogsTableField_Archived()
- protected GridField getPaymentsField()
- protected bool prepareAndSendEmail()
- protected ArrayData createReplacementArrayForEmail()
- protected DataList itemsFromDatabase()
- protected DataList modifiersFromDatabase()
- protected void calculateOrderItems()
- protected void calculateModifiers()
- protected void getMemberForCanFunctions()
- protected Order addHasOneAndHasManyAsVariables()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Implements
Tasks
Line | Task |
---|---|
+ | : how to translate this? |
3182+ | : why do we dont return a string IF there is only one item. |
3648+ | : move to more appropriate class |
Members
private
- $_needs_recalculating
—
array
Tells us if an order needs to be recalculated can save one for each order... - $_try_to_finalise_order_is_running — array
- $ajax_subtotal_format — array
- $ajax_total_format — array
- $api_access
—
array
API Control. - $casting
—
array
standard SS variable. - $csv_export_fields
- $date_format_for_title
—
string
see: http://userguide.icu-project.org/formatparse/datetime. - $db
- $default_sort
—
string
standard SS variable. - $description
—
string
Standard SS variable. - $has_many
—
array
standard SS variable. - $has_one
- $include_customer_name_in_title — Sunnysideup\Ecommerce\Model\bool
- $indexes
—
array
standard SS variable. - $maximum_ignorable_sales_payments_difference — float
- $minutes_an_order_can_be_viewed_without_logging_in — int
- $modifiers — array
- $order_id_start_number — int
- $plural_name
—
string
standard SS variable. -
$searchable_fields
STANDARD SILVERSTRIPE STUFF. - $singular_name
—
string
standard SS variable. - $summary_fields
—
array
STANDARD SILVERSTRIPE STUFF. - $table_name
—
array
standard SS variable. - $template_id_prefix — string
protected
- $_isSubmittedTempVar
—
Sunnysideup\Ecommerce\Model\bool
speeds up processing by storing the IsSubmitted value we start with -1 to know if it has been requested before. -
$_modifier_form_cache
Returns a set of modifier forms for use in the checkout order form, Controller is optional, because the orderForm has its own default controller. - $fieldsAndTabsToBeRemoved
—
array
fields that we remove from the parent::getCMSFields object set. - $order_cache — Sunnysideup\Ecommerce\Model\array[Order]
- $totalItems
—
int
Total Items : total items in cart We start with -1 to easily identify if it has been run before. - $totalItemsTimesQuantity
—
float
Total Items : total items in cart We start with -1 to easily identify if it has been run before.
Methods
protected
- addHasOneAndHasManyAsVariables() — returns itself wtih more data added as variables.
- calculateModifiers() — Calculates and updates all the modifiers.
- calculateOrderItems() — Calculates and updates all the product items.
- createReplacementArrayForEmail() — returns the Data that can be used in the body of an order Email we add the subject here so that the subject, for example, can be added to the <title> of the email template.
- getBillingAddressField()
- getMemberForCanFunctions()
- getOrderItemsField() — Field to add and edit Order Items.
- getOrderStatusLogsTableField_Archived()
- getPaymentsField()
- getShippingAddressField()
- itemsFromDatabase() — Return all the {@link OrderItem} instances that are available as records in the database.
- modifiersFromDatabase() — Get all {@link OrderModifier} instances that are available as records in the database.
- onAfterWrite() — standard SS method adds the ability to update order after writing it.
- onBeforeDelete() — standard SS method.
- onBeforeWrite()
- prepareAndSendEmail() — Send a mail of the order to the client (and another to the admin).
public
- AJAXDefinitions() — returns the instance of EcommerceConfigAjax for use in templates.
- Archive() — returns true if successful.
- Buyables() — returns the buyables asscoiated with the order items.
- CMSEditLink() — link to edit the record.
- CanHaveShippingAddress() — Casted variable - does the order have a potential shipping address?
- CanViewOrderStatusLogs() — Returns all the order logs that the current member can view i.e. some order logs can only be viewed by the admin (e.g. suspected fraud orderlog).
- Cancel() — cancel an order.
- CheckoutLink() — returns the link to finalise the Order.
- ConvertToHTML() — Converts the Order into HTML, based on the Order ProductGroupSchema.
- ConvertToJSON() — Converts the Order into a JSON object.
- ConvertToString() — Converts the Order into a serialized string.
- CopyOrderLink() — link to copy order.
- Country()
- CreateOrReturnExistingAddress() — Returns either the existing one or a new Order Address...
- CreateOrReturnExistingMember() — Returns a member linked to the order.
- CurrentStepVisibleToCustomer()
- CustomerStatus() — Casted variable - has the order been submitted?
- CustomerViewableOrderStatusLogs() — returns all the logs that can be viewed by the customer.
- DeleteLink() — link to delete order.
- DisplayPage() — returns the link to view the Order WHY NOT CHECKOUT PAGE: first we check for cart page.
- EmailLink() — returns the absolute link to the order that can be used in the customer communication (email).
- EnsureCorrectExchangeRate() — Makes sure exchange rate is updated and maintained before order is submitted This method is public because it could be called from a shopping Cart Object.
- ExpectedCountryName()
- FeedbackLink()
- FixedCountry() — return the title of the fixed country (if any).
- FullNameCountry()
- HasAlternativeCurrency() — Casted variable Currency is not the same as the standard one?
- HasPrintOrEmailLink() — Returns true if there is a prink or email link.
- IsAdminCancelled() — Has the order been cancelled by the administrator?
- IsArchived()
- IsCancelled() — Has the order been cancelled?
- IsCancelledNice()
- IsCompleted() — Is the order completed?
- IsCustomerCancelled() — Has the order been cancelled by the customer?
- IsFirstStep() — works out if the order is still at the first OrderStep.
- IsInCart() — Is the order still being "edited" by the customer?
- IsInSession()
- IsPaid() — Has the order been paid? TODO: why do we check if there is a total at all?
- IsPaidNice()
- IsPastCart() — The order has "passed" the IsInCart phase.
- IsProcessing() — Is the order in the :"processing" phaase.?
- IsSeparateShippingAddress() — is this a gift / separate shippingAddress?
- IsSubmitted() — Casted variable - has the order been submitted? alias.
- IsUncomplete() — Are there still steps the order needs to go through?
- Items() — Returns the items of the order.
- LessSecureSessionID() — returns a pseudo random part of the session id.
- Link() — returns the link to view the Order WHY NOT CHECKOUT PAGE: first we check for cart page.
- Modifiers() — Returns the modifiers of the order, if it hasn't been saved yet it returns the modifiers from session, if it has, it returns them from the DB entry. ONLY USE OUTSIDE ORDER.
- ModifiersSubTotal() — Returns the subtotal of the modifiers for this order.
- ModifiersSubTotalAsCurrencyObject()
- ModifiersSubTotalAsMoneyObject()
- MoreThanOneItemInCart() — Little shorthand.
- MyStep() — Avoids caching of $this->Status().
- OrderDate() — Submission Log for this Order (if any).
- OrderEmail() — returns the email to be used for customer communication.
- OrderItems()
- OrderItemsSummaryAsHTML()
- OrderItemsSummaryNice()
- OrderModifiers()
- OrderStepField()
- PackingSlipLink() — returns the absolute link to the order for printing.
- PaymentIsPending() — Has the order been paid? TODO: why do we check if there is a total at all?
- PrintLink() — returns the absolute link to the order for printing.
- Region() — Returns the region that applies to the order.
- RelevantLogEntry() — Return the OrderStatusLog that is relevant to the Order status.
- RelevantPayments() — shows payments that are meaningfull if the order has been paid then only show successful payments.
- RetrieveLink() — returns the absolute link that the customer can use to retrieve the email WITHOUT logging in.
- RetrieveModifier() — returns a modifier that is an instanceof the classname it extends.
- SecondsSinceBeingSubmitted()
- SetCountryFields() — Sets the country in the billing and shipping address.
- SetCurrency() — alias for UpdateCurrency.
- SetRegionFields() — Sets the region in the billing and shipping address.
- ShopClosed() — Is the Shop Closed for business?
- SubTotal() — Returns the subtotal of the items for this order.
- SubTotalAsCurrencyObject()
- SubTotalAsMoney()
- SubTotalCartValue()
- SubmissionLog() — Submission Log for this Order (if any).
- SubmitErrors() — if the order can not be submitted, then the reasons why it can not be submitted will be returned by this method.
- Title() — A "Title" for the order, which summarises the main details (date, and customer) in a string.
- Total() — Returns the total cost of an order including the additional charges or deductions of its modifiers.
- TotalAsCurrencyObject()
- TotalAsMoney()
- TotalItems() — returns the total number of OrderItems (not modifiers).
- TotalItemsTimesQuantity() — returns the total number of OrderItems (not modifiers) times their respectective quantities.
- TotalOutstanding() — Checks to see if any payments have been made on this order and if so, subracts the payment amount from the order.
- TotalOutstandingAsCurrencyObject()
- TotalOutstandingAsMoney()
- TotalPaid()
- TotalPaidAsCurrencyObject()
- TotalPaidAsMoney()
- UpdateCurrency() — Stores the preferred currency of the order.
- calculateOrderAttributes() — Calculates and updates all the order attributes.
- canCancel() — Can the given member cancel this order?
- canCheckout() — is the order ready to go through to the checkout process.
- canCreate()
- canDelete()
- canEdit() — if we set canEdit to false then we can not see the child records Basically, you can edit when you can view and canEdit (even as a customer) Or if you are a Shop Admin you can always edit.
- canOverridecanView()
- canPay() — Can a payment be made for this Order?
- canSubmit() — Can the order be submitted? this method can be used to stop an order from being submitted due to something not being completed or done.
- canView() — Standard SS method - can the current member view this order?
- canViewAdminStuff()
- debug() — Debug helper method.
- doNextStatus() — Goes through the order steps and tries to "apply" the next step Step is updated after the other one is completed...
- getCMSFields() — STANDARD SILVERSTRIPE STUFF broken up into submitted and not (yet) submitted.
- getCanHaveShippingAddress()
- getCopyOrderLink()
- getCountry() — Returns the country code for the country that applies to the order.
- getCustomer()
- getCustomerStatus()
- getDeleteLink()
- getEmailLink()
- getEmailsTableField()
- getExpectedCountryName() — returns name of coutry that we expect the customer to have This takes into consideration more than just what has been entered for example, it looks at GEO IP.
- getExportFields() — fields contains in CSV export for ModelAdmin GridField.
- getFeedbackLink()
- getFixedCountry()
- getFullNameCountry() — returns name of coutry.
- getHasAlternativeCurrency()
- getIsCancelled()
- getIsCancelledNice()
- getIsPaidNice()
- getIsSubmitted() — Casted variable - has the order been submitted?
- getModifierForms()
- getModifierTableField() — Field to add and edit Modifiers.
- getOrderAttributesByType() — returns a list of Order Attributes by type.
- getOrderEmail()
- getOrderItemsSummaryNice()
- getOrderStatusLogsTableField() — Needs to be public because the OrderStep::getCMSFIelds accesses it.
- getOrderStatusLogsTableFieldEditable() — Needs to be public because the OrderStep::getCMSFIelds accesses it.
- getPackingSlipLink()
- getPrintLink()
- getRegion()
- getRetrieveLink()
- getSubTotal()
- getSubTotalAsMoney()
- getTitle()
- getTotal()
- getTotalAsMoney()
- getTotalItems()
- getTotalItemsTimesQuantity()
- getTotalOutstanding()
- getTotalOutstandingAsMoney()
- getTotalPaid()
- getTotalPaidAsMoney()
- get_by_id_if_can_view() — Like the standard byID, but it checks whether we are allowed to view the order.
- get_datalist_of_orders_with_joined_submission_record()
- get_datalist_of_orders_with_submit_record() — returns a Datalist with the submitted order log included this allows you to sort the orders by their submit dates.
- get_needs_recalculating()
- get_order_cached()
- get_order_status_options() — This function returns the OrderSteps.
- i18n_plural_name()
- i18n_singular_name()
- init() — init runs on start of a new Order (@see onAfterWrite) it adds all the modifiers to the orders and the starting OrderStep.
- renderOrderInEmailFormat() — returns the order formatted as an email.
- scaffoldSearchFields() — Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.
- sendAdminNotification() — Sends a message to the shop admin ONLY and not to the customer This can be used by ordersteps and orderlogs to notify the admin of any potential problems.
- sendEmail() — Send the invoice of the order by email.
- set_needs_recalculating()
- set_order_cached()
- tryToFinaliseOrder() — Goes through the order steps and tries to "apply" the next status to the order.
- updateForAjax() — Collects the JSON data for an ajax return of the cart.