Shop_Order
The Shop_Order class represents a customer order. You may want to know details about this class if you are developing the Order Details page and want to output details about a specific order.
Parent class: Db_ActiveRecord
Class fields
- $id – order identifier
- $order_datetime – a date and time when the order was placed. An object of class Phpr_DateTime.
- $shipping_method – a reference to a shipping method, selected by a customer for the order. An object of the Shop_ShippingOption class.
- $customer – a reference to the customer who placed the order. An object of the Shop_Customer class
- $payment_method – a reference to a payment method, selected by a customer for the order. An object of the Shop_PaymentMethod class.
- $billing_first_name – a customer billing first name
- $billing_last_name – a customer billing last name
- $billing_email – a customer email address
- $billing_phone – customer billing phone number
- $billing_company - customer billing company
- $billing_street_addr – billing string address
- $billing_city – billing city
- $billing_state – a billing state. An object of the Shop_CountryState class
- $billing_zip – a billing ZIP code
- $billing_country – a billing country. An object of the Shop_Country class
- $coupon - a Shop_Coupon object, representing a coupon specified by the customer during the order checkout. The Shop_Coupon object contains only one field - $code, which is the coupon textual code.
- $shipping_first_name – a customer shipping first name
- $shipping_last_name – a customer shipping last name
- $shipping_phone – a customer shipping phone number
- $shipping_company – a customer shipping company
- $shipping_street_addr – a customer shipping street address
- $shipping_city – shipping city
- $shipping_state – a shipping state. An object of the Shop_CountryState class
- $shipping_zip – a shipping ZIP code
- $shipping_country – shipping country. An object of Shop_Country class
- $status – current order status. An object of the Shop_OrderStatus class.
- $status_update_datetime – date and time when the order status has been changed last time. An object of the Phpr_DateTime class.
- $items – a collection of order items. An object of the Db_DataCollection class. Each element is the collection is an object of the Shop_OrderItem class.
- $order_notes - order notes provided by the customer
Monetary fields
- $discount - total order discount.
- $discount_tax_incl - total order discount, tax inclusive
- $goods_tax – a value of the goods tax
- $shipping_quote – a value of the shipping quote
- $shipping_quote_tax_incl - shipping quote, tax inclusive
- $shipping_tax – a value of the shipping tax
- $subtotal – order subtotal sum - a sum of the order items totals.
- $subtotal_tax_incl - order subtotal, tax inclusive
- $tax_total - a total tax value evaluated as $goods_tax + $shipping_tax.
- $total – order total amount. It includes the subtotal value, tax value and the shipping quote value. The discount value is already subtracted from the $total value.
Class methods
- is_paid() - returns true if the order has Paid status, or the Paid status is in the order status history.
- payment_processed() - returns true if a customer has been successfully paid the order.
- list_item_taxes() - returns a list of taxes applied to order items. Return value: array. Each element in the array is an object containing the following fields:
- name - the tax name, for example GST,
- total - total tax value
You can use this method for displaying a list of order taxes on the order receipt page, for example:Applied taxes: <? foreach ($order->list_item_taxes() as $tax): ?> <?= ($tax->name) ?>: <?= format_currency($tax->total) ?><br/> <? endforeach ?>
- list_shipping_taxes() - returns a list of taxes applied to the order shipping service. Returns array. Please see the list_item_taxes() method for details about the array elements.
- list_all_taxes() - returns a list of all taxes, including sales and shipping taxes. Returns array. Please see the list_item_taxes() method for details about the array elements.
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). The payment methods in LemonStand can be configured in a way so 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 usual usage for the payment_processed method is hiding the Pay button on the order details page. The usual usage for the is_paid method is restricting customer's access to product files when you sell downloadable products.
See also:
- Shop_Customer class
- Shop_Country class
- Shop_CountryState class
- Shop_OrderStatus class
- Shop_OrderItem class
- Phpr_DateTime class
Next: Shop_OrderItem
Previous: Shop_Manufacturer
Return to API (function, action and class reference)
Comments
No comments posted so far.
Add your comment
Loading form...