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_OrderItem class

Defined in /modules/shop/models/shop_orderitem.php, lines 39-1366
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Shop_OrderItem
Author LemonStand eCommerce Inc.
Represents an item of an order. Objects of this class are created by LemonStand when a new order is placed. You may need to work with order item objects on Order Details page and Payment Receipt pages.

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
bundle_item_total float specifies a total price of a bundle item (total price of the bundle item in a single base product). Shop_OrderItem
bundle_item_total_tax_incl float specifies a total price of a bundle item, tax inclusive. Shop_OrderItem
bundle_master_order_item_id integer specifies an identifier of an order item representing base bundle product for this order item. Shop_OrderItem
discount float specifies the item discount value. Shop_OrderItem
discount_tax_included float specifies the the item discount amount, tax inclusive. Shop_OrderItem
fetched array contains an associative array of table column values fetched from the database. Db_ActiveRecord
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
price float specifies a price of a unit item without a price of extra options and without the discount applied. Shop_OrderItem
price_tax_included float specifies the item price (including extras), tax inclusive. Shop_OrderItem
primary_key string specifies a name of the table primary key. Db_ActiveRecord
product Shop_Product a product object associated with the order item. Shop_OrderItem
product_name string specifies a name of a product associated with the order item. Shop_OrderItem
product_sku string specifies a SKU of a product associated with the order item. Shop_OrderItem
quantity integer specifies a quantity of the order item. Shop_OrderItem
single_price float specifies a price of a unit item, including a price of extra options. Shop_OrderItem
subtotal float specifies the subtotal: (item price - discount)*quantity. Shop_OrderItem
subtotal_tax_incl float specifies the subtotal, tax inclusive. Shop_OrderItem
tax float specifies a sales tax value calculated for a unit item (ignoring the item quantity). Shop_OrderItem
tax_2 float specifies a second sales tax value, if applicable. Shop_OrderItem
tax_name_1 string specifies a name of the first sales tax applied. Shop_OrderItem
tax_name_2 string specifies a name of the second sales tax applied. Shop_OrderItem
uploaded_files Db_DataCollection a collection of files uploaded by the customer on the Product Details page. Shop_OrderItem
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_create_saved() 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_validation() triggered after the model column values are validated. 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
before_create() called before a new object is saved to the database. Db_ActiveRecord
before_delete() called before a record is deleted from the database. Db_ActiveRecord
before_update() called before an existing record is 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
convert_to_cart_item() returns a cart item object with property values based on the order item properties. Shop_OrderItem
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
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_bundle_discount() returns total discount of a bundle. Shop_OrderItem
get_bundle_item_quantity() returns quantity of the bundle item product in each bundle. Shop_OrderItem
get_bundle_single_price() returns unit price of a bundle. The price includes prices of all bundle items. Shop_OrderItem
get_bundle_total_price() returns total bundle price. Shop_OrderItem
get_extra_options() returns an array of extra options selected by the customer. Shop_OrderItem
get_extra_option_objects() returns a list of extra options selected by the customer. Shop_OrderItem
get_master_bundle_order_item() returns order item representing a master bundle product for this item. Shop_OrderItem
get_om_record() returns an Option Matrix record basing on selected product options. Shop_OrderItem
get_options() returns an array of product options selected by the customer. Shop_OrderItem
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_bundle_items() returns a list of order items representing bundle items which master product is represented by this item. Shop_OrderItem
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
om() returns Option Matrix product property. Shop_OrderItem
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_name() returns a string describing the order item. Shop_OrderItem
paginate() allows to limit the result of the find_all() method with a single page of records. Db_ActiveRecord
requestRowCount() returns a number of rows which would be returned with find_all() method. Db_ActiveRecord
save() saves record to the database. Db_ActiveRecord
total_depth() returns the total depth of the order item. Shop_OrderItem
total_height() returns the total width of the order item. Shop_OrderItem
total_volume() returns the total volume of the order item. Shop_OrderItem
total_weight() returns the total weight of the order item. Shop_OrderItem
total_width() returns the total width of the order item. Shop_OrderItem
where() allows to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase

Events

Event Description
shop:onBeforeOrderItemSaved Triggered before an order item is saved to the database.
shop:onExtendOrderItemForm Allows to add new fields to the Create/Edit Order Item form in the Administration Area.
shop:onExtendOrderItemModel Allows to define new columns in the order item model.
shop:onGetOrderItemDisplayDetails Allows to display custom information about an order item in the Administration Area, for example on the Order Preview page.
shop:onGetOrderItemFieldOptions Allows to populate drop-down, radio- or checkbox list fields, which have been added with shop:onExtendOrderItemForm event.
shop:onNewInvoiceItemCopy Allows to update an order item in a new invoice, when the invoice is created manually in the Administration Area.
shop:onOrderItemAdded Triggered when an order item is added to an order.
shop:onOrderItemDeleted Triggered after an order item is deleted from an order.
shop:onOrderItemUpdated Triggered when an order item is updated.

Property details

bundle_item_total property

public float $bundle_item_total;
Specifies a total price of a bundle item (total price of the bundle item in a single base product). If the order item does not represent a bundle item product, the field value matches the $total_price field value.

bundle_item_total_tax_incl property

public float $bundle_item_total_tax_incl;
Specifies a total price of a bundle item, tax inclusive.

bundle_master_order_item_id property

public integer $bundle_master_order_item_id;
Specifies an identifier of an order item representing base bundle product for this order item. This field is not empty for bundle item products.

discount property

public float $discount;
Specifies the item discount value.

discount_tax_included property

public float $discount_tax_included;
Specifies the the item discount amount, tax inclusive.

price property

public float $price;
Specifies a price of a unit item without a price of extra options and without the discount applied.

price_tax_included property

public float $price_tax_included;
Specifies the item price (including extras), tax inclusive.

product property

public Shop_Product $product;
A product object associated with the order item.

product_name property

public string $product_name;
Specifies a name of a product associated with the order item.

product_sku property

public string $product_sku;
Specifies a SKU of a product associated with the order item.

quantity property

public integer $quantity;
Specifies a quantity of the order item.

single_price property

public float $single_price;
Specifies a price of a unit item, including a price of extra options. To get a total unit item price subtract the discount value from this property value.

subtotal property

public float $subtotal;
Specifies the subtotal: (item price - discount)*quantity.

subtotal_tax_incl property

public float $subtotal_tax_incl;
Specifies the subtotal, tax inclusive.

tax property

public float $tax;
Specifies a sales tax value calculated for a unit item (ignoring the item quantity). The tax is calculated as the unit price + extra options prices.

tax_2 property

public float $tax_2;
Specifies a second sales tax value, if applicable.

tax_name_1 property

public string $tax_name_1;
Specifies a name of the first sales tax applied.

tax_name_2 property

public string $tax_name_2;
Specifies a name of the second sales tax applied.

uploaded_files property

public Db_DataCollection $uploaded_files;
A collection of files uploaded by the customer on the Product Details page. Each element in the collection is an object of the Db_File class.

Method details

convert_to_cart_item() method

public Shop_CartItem convert_to_cart_item()
{return} Shop_CartItem returns a cart item object.
Returns a cart item object with property values based on the order item properties. A reference to the original order item is stored in the $order_item property of the new cart item object.

get_bundle_discount() method

public float get_bundle_discount()
{return} float returns total discount of a bundle.
Returns total discount of a bundle. The discount includes discounts of all bundle items.

get_bundle_item_quantity() method

public integer get_bundle_item_quantity()
{return} integer returns quantity of the bundle item product in each bundle.
Returns quantity of the bundle item product in each bundle. If the order item does not represent a bundle item, returns the $quantity property value.

get_bundle_single_price() method

public float get_bundle_single_price()
{return} float returns unit price of a bundle.
Returns unit price of a bundle. The price includes prices of all bundle items.

get_bundle_total_price() method

public float get_bundle_total_price()
{return} float returns total bundle price.
Returns total bundle price.

get_extra_options() method

public array get_extra_options()
{return} array returns an array of extra option names and prices.
Returns an array of extra options selected by the customer. Each element of the array is another array with 2 elements. The first elements corresponds an option price, and the second element corresponds the option name. For example: array(12.5, 'Extra 125 Mb RAM') If you need to extract a list of Shop_ExtraOption objects use get_extra_option_objects() method.

get_extra_option_objects() method

public array get_extra_option_objects()
{return} array returns an array of Shop_ExtraOption objects.
Returns a list of extra options selected by the customer.

get_master_bundle_order_item() method

public Shop_OrderItem get_master_bundle_order_item()
{return} Shop_OrderItem returns order item representing a master bundle product for this item. Returns NULL if the order item is not found.
Returns order item representing a master bundle product for this item.

get_om_record() method

public Shop_OptionMatrixRecord get_om_record()
{return} Shop_OptionMatrixRecord returns the Option Matrix record object or NULL.
Returns an Option Matrix record basing on selected product options.

get_options() method

public array get_options()
{return} array returns an array of option names and values.
Returns an array of product options selected by the customer. Each element of the array is another array with keys corresponding option names and values corresponding option values, for example: array('color'=>'yellow', 'size'=>'small')

list_bundle_items() method

public array list_bundle_items()
{return} array returns an array of Shop_OrderItem objects.
Returns a list of order items representing bundle items which master product is represented by this item.

om() method

public mixed om(string $property_name, mixed $options=NULL)
$property_name string specifies the property name.
$options mixed specifies product option values or Shop_OptionMatrixRecord object. Options should be specified in the following format: ['option_key_1'=>'option value 1', 'option_key_2'=>'option value 2'] Option keys and values are case sensitive.
{return} mixed returns the property value or NULL.
Returns Option Matrix product property. If Option Matrix product is not associated with the order item, returns property value of the base product. Specify the property name in the first parameter. Use the method on the Order Details page or Payment Receipt page to output Option Matrix specific parameters, for example product images. The following example outputs a product image in the order item list.
<?
  $images = $item->om('images');
  $image_url = $images->count ? $images->first->getThumbnailPath(60, 'auto') : null;
?>

<? if ($image_url): ?>
  <img class="product_image" src="<?= $image_url ?>" alt="<?= h($item->product->name) ?>"/>
<? endif ?>
The $options parameter used by LemonStand internally.

output_product_name() method

public string output_product_name(boolean $output_name=true, boolean $as_plain_text=false, boolean $no_tax_incl=false, boolean $extra_details=false, string $options_delimiter='; ', boolean $lowercase_options=NULL)
$output_name boolean determines whether the product name should be included to the result.
$as_plain_text boolean determines whether the result string should not include any HTML tags. By default the method returns a HTML string.
$no_tax_incl boolean determines whether taxes should not be included to the extra option prices. By default the function uses the tax inclusive settings.
$extra_details boolean enables the shop:onGetOrderItemDisplayDetails event, which allows to add extra details to the result string.
$options_delimiter string specifies a delimiter string for options.
$lowercase_options boolean convert options values to lower case.
{return} string returns a string describing the item.
Returns a string describing the order item. The string contains the product name, options and extra options. The result of this method can be customized with shop:onGetOrderItemDisplayDetails event.

total_depth() method

public float total_depth()
{return} float returns the item total depth.
Returns the total depth of the order item. The total depth is unit depth * quantity.

total_height() method

public float total_height()
{return} float returns the item total height.
Returns the total width of the order item. The total height is unit height * quantity.

total_volume() method

public float total_volume()
{return} float returns the item total volume.
Returns the total volume of the order item. The total depth is unit volume * quantity.

total_weight() method

public float total_weight()
{return} float returns the item total weight.
Returns the total weight of the order item. The total depth is unit weight * quantity.

total_width() method

public float total_width()
{return} float returns the item total width.
Returns the total width of the order item. The total depth is unit depth * quantity.