This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Shop_Order class

Defined in /modules/shop/models/shop_order.php, lines 63-2777
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Shop_Order
Author LemonStand eCommerce Inc.
Represents an order.

Public properties

Show inherited properties.

Property Type Description Defined By
auto_create_timestamps array a list of create timestamp columns. Db_ActiveRecord
auto_timestamps boolean determines whether create and update timestamp field should be set automatically. Db_ActiveRecord
auto_update_timestamps array a list of update timestamp columns. Db_ActiveRecord
billing_city string specifies the customer billing city. Shop_Order
billing_company string specifies the customer billing company. Shop_Order
billing_country Shop_Country a reference to the billing country. Shop_Order
billing_email string specifies the customer email address. Shop_Order
billing_first_name string specifies the customer billing first name. Shop_Order
billing_last_name string specifies the customer billing last name. Shop_Order
billing_phone string specifies the customer billing phone number. Shop_Order
billing_state Shop_CountryState a reference to the billing state. Shop_Order
billing_street_addr string specifies the customer billing address. Shop_Order
billing_zip string specifies a billing ZIP/postal code. Shop_Order
coupon Shop_Coupon an object, representing a coupon applied to the order, if any. Shop_Order
customer Shop_Customer a reference to the customer who placed the order. Shop_Order
customer_ip string customer's IP address. Shop_Order
deleted_at Phpr_DateTime specifies a date and time when the order was marked as deleted. Shop_Order
discount float total order discount. Shop_Order
discount_tax_incl float total order discount, tax inclusive. Shop_Order
fetched array contains an associative array of table column values fetched from the database. Db_ActiveRecord
free_shipping boolean indicates whether free shipping is applied to the order. Shop_Order
goods_tax float total value of the sales tax. Shop_Order
has_and_belongs_to_many array contains a list of Has and Belongs To Many relations. Db_ActiveRecord
has_one array contains a list of Has One relations. Db_ActiveRecord
id integer specifies the order record identifier. Shop_Order
items Db_DataCollection a collection of order items. Shop_Order
order_datetime Phpr_DateTime specifies a date and time when the order was placed. Shop_Order
order_notes string specifies order notes provided by the customer. Shop_Order
payment_method Shop_PaymentMethod a reference to a payment method, selected by the customer for the order. Shop_Order
primary_key string specifies a name of the table primary key. Db_ActiveRecord
shipping_city string specifies the customer shipping city. Shop_Order
shipping_company string specifies the customer shipping company. Shop_Order
shipping_country Shop_Country a reference to the shipping country. Shop_Order
shipping_first_name string specifies the customer shipping first name. Shop_Order
shipping_last_name string specifies the customer shipping last name. Shop_Order
shipping_method Shop_ShippingOption a reference to a shipping method, selected by the customer for the order. Shop_Order
shipping_phone string specifies the customer shipping phone number. Shop_Order
shipping_quote float value of the shipping quote. Shop_Order
shipping_quote_tax_incl float shipping quote, tax inclusive. Shop_Order
shipping_state Shop_CountryState a reference to the shipping state. Shop_Order
shipping_street_addr string specifies the customer shipping street address. Shop_Order
shipping_sub_option string specifies a shipping method sub-option name, if any. Shop_Order
shipping_tax float value of the shipping tax. Shop_Order
shipping_zip string specifies a shipping ZIP/postal code. Shop_Order
status Shop_OrderStatus a reference to the current order status. Shop_Order
status_update_datetime Phpr_DateTime a reference to the date/time object representing date and time when the order status has been updated last time. Shop_Order
subtotal float order subtotal sum - a sum of the order item totals. Shop_Order
subtotal_before_discounts float subtotal before the discount applied. Shop_Order
subtotal_tax_incl float order subtotal, tax inclusive. Shop_Order
tax_total float total tax value: $goods_tax + $shipping_tax. Shop_Order
total float total order amount. Shop_Order
validation Phpr_Validation contains the model's validation object. Db_ActiveRecord

Public methods

Show inherited methods.

Method Description Defined By
add_form_custom_area() adds a form custom area. Db_ActiveRecord
add_form_field() makes a column visible in forms. Db_ActiveRecord
add_form_partial() adds a custom form partial. Db_ActiveRecord
add_form_section() adds a form section. Db_ActiveRecord
after_create() called after a new object is saved to the database. Db_ActiveRecord
after_modify() called after an existing or new record was modified. Db_ActiveRecord
after_save() called after an existing or new record is created or updated in the database. Db_ActiveRecord
after_update() called after an existing record is updated in the database. Db_ActiveRecord
after_validation_on_create() triggered after a new model column values are validated. Db_ActiveRecord
after_validation_on_update() triggered after an existing model column values are validated. Db_ActiveRecord
automated_billing_supported() determines whether there are any modules which support automated billing. Shop_Order
before_delete() called before a record is deleted from the database. Db_ActiveRecord
before_save() called before an existing or new record is created or updated in the database. Db_ActiveRecord
before_validation() triggered before the model column values are validated. Db_ActiveRecord
before_validation_on_create() triggered before a new model column values are validated. Db_ActiveRecord
before_validation_on_update() triggered before an existing model column values are validated. Db_ActiveRecord
collection() executes the find_all() method and returns a collection. Db_ActiveRecord
columnValue() alias for the displayField() method. Db_ActiveRecord
define_column() adds a column definition to the model. Db_ActiveRecord
define_multi_relation_column() adds column definition for has_and_belongs_to_many or has_many relation field. Db_ActiveRecord
define_relation_column() adds column definition for has_on or belongs_to relation field. Db_ActiveRecord
delete() deletes the record from the database. Db_ActiveRecord
delete_form_field() deletes a form field by its corresponding column name. Db_ActiveRecord
delete_order() marks the order as deleted. Shop_Order
displayField() returns a formatted column value. The field should be defined with define_column(), Db_ActiveRecord
find() finds a record by its primary key value. Db_ActiveRecord
find_all() finds all records and returns the Db_DataCollection object, containing a list of models. Db_ActiveRecord
find_by() finds a record by a field value. Db_ActiveRecord
find_column_definition() finds a column definition by the column name. Db_ActiveRecord
find_form_field() finds a form field definition by its corresponding column name. Db_ActiveRecord
get_payment_page_url() returns URL of the order payment page URL. Shop_Order
get_shipping_address_info() returns shipping address information object. Shop_Order
invoices_supported() determines whether the order contains any products which support invoices. Shop_Order
invoice_system_supported() determines whether there are any modules which support invoices. Shop_Order
is_paid() returns TRUE if the order has Paid status, or the Paid status is in the order status history. Shop_Order
join() adds a table to the query with JOIN statement. Db_SqlBase
limit() allows to limit the result of the find_all() method with the specified number of records. Db_ActiveRecord
list_all_taxes() returns a list of sales and shipping taxes applied to the order. Shop_Order
list_invoices() returns a list of invoices. Shop_Order
list_item_taxes() returns a list of taxes applied to order items. Shop_Order
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
list_shipping_taxes() returns a list of taxes applied to the order shipping service. Shop_Order
order() allows to order the result of the find_all() method by a specific table column. Db_SqlBase
orWhere() adds OR statement to the where clause, allowing to to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase
output_product_file() outputs a file of a downloadable product. Shop_Order
paginate() allows to limit the result of the find_all() method with a single page of records. Db_ActiveRecord
payment_processed() returns TRUE if a customer has successfully paid the order. Shop_Order
place_order() creates an order from data collected during the checkout process. Shop_Order
requestRowCount() returns a number of rows which would be returned with find_all() method. Db_ActiveRecord
restore_order() restores an order previously marked as deleted with delete_order() method. Shop_Order
save() saves record to the database. Db_ActiveRecord
set_payment_processed() updates the internal flag which indicates whether the order's payment has been processed. Shop_Order
where() allows to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase

Events

Event Description
shop:onAfterOrderRecordFetch Triggered after an order record is fetched from the database.
shop:onAutomatedBillingSupported Allows to enable the automated bulling features in LemonStand.
shop:onBeforeDeleteShippingTrackingCode Triggered before a shipping tracking code is deleted.
shop:onBeforeOrderRecordCreate Triggered before a new order record is saved to the database.
shop:onBeforeOrdersRssExport Triggered before orders RSS feed is generated.
shop:onConfigureOrdersPage Allows to configure the Administration Area order pages before they are displayed.
shop:onDisplayOrdersPage Allows to load extra CSS or JavaScript files on the Order List, Order Preview, Create/Edit Order and other back-end pages related to orders.
shop:onExtendOrderForm Allows to add new fields to the Create/Edit Order and Preview Order forms in the Administration Area.
shop:onExtendOrderInvoicesToolbar Allows to add new button to the toolbar above the Invoice List on the Order Preview page in the Administration Area.
shop:onExtendOrderModel Allows to define new columns in the order model.
shop:onExtendOrderPaymentTransactionsToolbar Allows to add new buttons to the toolbar above the Payment Transactions list on Order Preview page in the Administration Area.
shop:onExtendOrderPreviewHeader Allows to display custom partials in the header of the Order Preview page in the Administration Area.
shop:onExtendOrderPreviewTabs Allows to display custom tabs on the Order Preview page in the Administration Area.
shop:onExtendOrderPreviewToolbar Allows to add new buttons to the toolbar above the Order Preview form.
shop:onExtendOrdersToolbar Allows to add new buttons to the toolbar above the order list in the Administration Area.
shop:onGetOrderFieldOptions Allows to populate drop-down, radio- or checkbox list fields, which have been added with shop:onExtendOrderForm event.
shop:onGetOrderFieldState Determines whether a custom radio button or checkbox list option is checked.
shop:onInvoiceSystemSupported Allows to enable the invoice support in LemonStand.
shop:onNewOrder Triggered after a new order is placed.
shop:onOrderAfterDelete Triggered after an order record has been deleted.
shop:onOrderBeforeCreate Allows you to alter the checkout information or cart content before an order is placed.
shop:onOrderBeforeUpdate Triggered before an existing order record is saved to the database.
shop:onOrderCopyBillingAddress Triggered when order billing information is copied to shipping information.
shop:onOrderError Triggered if an error occurs during the order placement.
shop:onOrderMarkedDeleted Triggered after an order has been marked deleted with Shop_Order::delete_order() method.
shop:onOrderRestored Triggered after an order has been restored with Shop_Order::restore_order() method.
shop:onOrderSupportsInvoices Allows to enable the invoice support for a specific order.

Property details

billing_city property

public string $billing_city;
Specifies the customer billing city.

billing_company property

public string $billing_company;
Specifies the customer billing company.

billing_country property

public Shop_Country $billing_country;
A reference to the billing country.

billing_email property

public string $billing_email;
Specifies the customer email address.

billing_first_name property

public string $billing_first_name;
Specifies the customer billing first name.

billing_last_name property

public string $billing_last_name;
Specifies the customer billing last name.

billing_phone property

public string $billing_phone;
Specifies the customer billing phone number.

billing_state property

public Shop_CountryState $billing_state;
A reference to the billing state.

billing_street_addr property

public string $billing_street_addr;
Specifies the customer billing address.

billing_zip property

public string $billing_zip;
Specifies a billing ZIP/postal code.

coupon property

public Shop_Coupon $coupon;
An object, representing a coupon applied to the order, if any. The Shop_Coupon object has the $code property, which contains the coupon code.

customer property

public Shop_Customer $customer;
A reference to the customer who placed the order.

customer_ip property

public string $customer_ip;
Customer's IP address.

deleted_at property

public Phpr_DateTime $deleted_at;
Specifies a date and time when the order was marked as deleted. See delete_order() method.

discount property

public float $discount;
Total order discount.

discount_tax_incl property

public float $discount_tax_incl;
Total order discount, tax inclusive.

free_shipping property

public boolean $free_shipping;
Indicates whether free shipping is applied to the order.

goods_tax property

public float $goods_tax;
Total value of the sales tax.

id property

public integer $id;
Specifies the order record identifier.

items property

public Db_DataCollection $items;
A collection of order items. Each element is the collection is an object of the Shop_OrderItem class.

order_datetime property

public Phpr_DateTime $order_datetime;
Specifies a date and time when the order was placed.

order_notes property

public string $order_notes;
Specifies order notes provided by the customer.

payment_method property

public Shop_PaymentMethod $payment_method;
A reference to a payment method, selected by the customer for the order.

shipping_city property

public string $shipping_city;
Specifies the customer shipping city.

shipping_company property

public string $shipping_company;
Specifies the customer shipping company.

shipping_country property

public Shop_Country $shipping_country;
A reference to the shipping country.

shipping_first_name property

public string $shipping_first_name;
Specifies the customer shipping first name.

shipping_last_name property

public string $shipping_last_name;
Specifies the customer shipping last name.

shipping_method property

public Shop_ShippingOption $shipping_method;
A reference to a shipping method, selected by the customer for the order.

shipping_phone property

public string $shipping_phone;
Specifies the customer shipping phone number.

shipping_quote property

public float $shipping_quote;
Value of the shipping quote.

shipping_quote_tax_incl property

public float $shipping_quote_tax_incl;
Shipping quote, tax inclusive.

shipping_state property

public Shop_CountryState $shipping_state;
A reference to the shipping state.

shipping_street_addr property

public string $shipping_street_addr;
Specifies the customer shipping street address.

shipping_sub_option property

public string $shipping_sub_option;
Specifies a shipping method sub-option name, if any.

shipping_tax property

public float $shipping_tax;
Value of the shipping tax.

shipping_zip property

public string $shipping_zip;
Specifies a shipping ZIP/postal code.

status property

public Shop_OrderStatus $status;
A reference to the current order status. Usually the status information can be loaded with displayField() method. See Shop_OrderStatus class documentation for details.

status_update_datetime property

public Phpr_DateTime $status_update_datetime;
A reference to the date/time object representing date and time when the order status has been updated last time.

subtotal property

public float $subtotal;
Order subtotal sum - a sum of the order item totals.

subtotal_before_discounts property

public float $subtotal_before_discounts;
subtotal before the discount applied.

subtotal_tax_incl property

public float $subtotal_tax_incl;
Order subtotal, tax inclusive.

tax_total property

public float $tax_total;
Total tax value: $goods_tax + $shipping_tax.

total property

public float $total;
Total order amount. It includes the subtotal value, tax value and the shipping quote value. The discount value is already subtracted from the $total value.

Method details

automated_billing_supported() method

public static boolean automated_billing_supported()
{return} boolean returns TRUE if there are any modules which support automated billing. Returns FALSE otherwise.
Determines whether there are any modules which support automated billing

delete_order() method

public void delete_order()
Marks the order as deleted. Orders marked as deleted remain in the database and can be restored with the restore_order() method.

get_payment_page_url() method

public string get_payment_page_url()
{return} string returns the page URL. Returns NULL if the page is not found.
Returns URL of the order payment page URL. Use this method for creating links to the payment page for unpaid orders. Payment page is a page based on shop:pay action.

See Also

get_shipping_address_info() method

public Shop_CheckoutAddressInfo get_shipping_address_info()
{return} Shop_CheckoutAddressInfo returns an address information object.
Returns shipping address information object. The object is populated with shipping address information from the order.

invoices_supported() method

public boolean invoices_supported()
{return} boolean returns TRUE if the order contains any products which support invoices. Returns FALSE otherwise.
Determines whether the order contains any products which support invoices. Modules should handle the shop:onOrderSupportsInvoices event if they provide order invoices functionality.

invoice_system_supported() method

public static boolean invoice_system_supported()
{return} boolean returns TRUE if there are any modules which support invoices. Returns FALSE otherwise.
Determines whether there are any modules which support invoices.

is_paid() method

public boolean is_paid()
{return} boolean returns TRUE if the order is paid. Returns FALSE otherwise.
Returns TRUE if the order has Paid status, or the Paid status is in the order status history. The common usage for the is_paid() method is restricting customer's access to product files if you sell downloadable products.

list_all_taxes() method

public array list_all_taxes()
{return} array returns an array
Returns a list of sales and shipping taxes applied to the order. The method returns an array of objects containing the following fields:
  • name - the tax name, for example GST.
  • total - total tax value.
Use this method for displaying a list of order taxes on the order receipt page, for example:
Applied taxes:
  <? foreach ($order->list_all_taxes() as $tax): ?>
  <?= ($tax->name) ?>: <?= format_currency($tax->total) ?><br/>
<? endforeach ?>

list_invoices() method

public Db_DataCollection list_invoices()
{return} Db_DataCollection returns a collection of Shop_Order objects.
Returns a list of invoices. Invoices are orders which are grouped under the given order.

list_item_taxes() method

public array list_item_taxes()
{return} array returns an array
Returns a list of taxes applied to order items. The method returns an array of objects containing the following fields:
  • name - the tax name, for example GST.
  • total - total tax value.
Use this method for displaying a list of order taxes on the order receipt page, for example:
Applied sales taxes:
  <? foreach ($order->list_item_taxes() as $tax): ?>
  <?= ($tax->name) ?>: <?= format_currency($tax->total) ?><br/>
<? endforeach ?>

list_shipping_taxes() method

public array list_shipping_taxes(array $taxes=NULL)
$taxes array specifies a list of existing taxes. This parameter is used by LemonStand internally.
{return} array returns an array
Returns a list of taxes applied to the order shipping service. The method returns an array of objects containing the following fields:
  • name - the tax name, for example GST.
  • total - total tax value.
Use this method for displaying a list of order taxes on the order receipt page, for example:
Applied shipping taxes:
  <? foreach ($order->list_shipping_taxes() as $tax): ?>
  <?= ($tax->name) ?>: <?= format_currency($tax->total) ?><br/>
<? endforeach ?>

output_product_file() method

public void output_product_file(integer $file_id, string $mode='attachment')
$file_id integer specifies an identifier of a product file.
$mode string specifies the file disposition - attachment or inline. Depending on the mode the browser either displays the file contents or offers to download it.
Outputs a file of a downloadable product. This method allows to create custom pages for downloading product files. This method stops the script execution in case if the file is successfully returned to the browser. Please read the Integrating downloadable products documentation article for the usage examples.

payment_processed() method

public boolean payment_processed(boolean $use_cached=true)
$use_cached boolean determines whether subsequent calls of the method can use a cached value instead of loading it from the database each time.
{return} boolean returns TRUE if the order payment has been successfully processed.
Returns TRUE if a customer has successfully paid the order. The is_paid() and payment_processed() methods could return opposite results in a case when a customer have paid an order (the payment_processed() method will return TRUE), but you (a merchant) have not validated the payment and have not sent the order into the Paid status (the is_paid() method will return FALSE). Payment methods in LemonStand can be configured in such a way that a successful payment automatically sends an order to the Paid status. Another way is to automatically send the order to some pending status, validate the payment manually, and then send the order to the Paid status.
The common usage for the payment_processed() method is hiding the Pay button on the order details page. The common usage for the is_paid() method is restricting customer's access to product files when you sell downloadable products.

place_order() method

public static Shop_Order place_order(Shop_Customer $customer, boolean $register_customer=false, string $cart_name='main', array $options=array())
$customer Shop_Customer specifies an existing customer object. If this parameter is NULL a new customer will be created.
$register_customer boolean determines whether the customer should be registered. Registered customers can log into the store.
$cart_name string specifies a name of the shopping cart to load order items from.
$options array a list of options.
{return} Shop_Order returns the new order object.
Creates an order from data collected during the checkout process. The order uses data contained in Shop_CheckoutData object. The $options array can contain the customer_password element, containing a password for the new customer. This value is applicable only if $register_customer parameter is TRUE.
Cart content and checkout information can be altered by shop:onOrderBeforeCreate event handlers.

restore_order() method

public void restore_order()
Restores an order previously marked as deleted with delete_order() method.

set_payment_processed() method

public void set_payment_processed()
Updates the internal flag which indicates whether the order's payment has been processed. This method is used by payment modules internally.