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

Defined in /modules/shop/classes/shop_cartitem.php, lines 12-858
Author LemonStand eCommerce Inc.
Represents an item in the shopping cart. Normally you don't need to create objects of this class. To access the shopping cart items use the Shop_Cart class. Please read the Creating the Cart page article for examples of the class usage.

Public properties

Property Type Description Defined By
cart_name string specifies a name of the cart the item belongs to. Shop_CartItem
extra_options array an array of extra paid options, selected by a customer. Shop_CartItem
key string specifies the item key. Shop_CartItem
options array an array of selected product options. Shop_CartItem
order_item Shop_OrderItem specifies a reference to the original order item object. Shop_CartItem
postponed boolean determines whether the cart item is postponed. Shop_CartItem
product Shop_Product a product object corresponding to the cart item. Shop_CartItem
quantity integer specifies the product quantity. Shop_CartItem

Public methods

Method Description Defined By
bundle_item_total_price() returns total price of a bundle item cart item (total price of the bundle item in a single base product). Shop_CartItem
bundle_single_price() returns total price (sum if all bundle items) of a single unit of the bundle product cart item. Shop_CartItem
bundle_total_discount() returns total discount of a single item of the bundle product cart item. Shop_CartItem
bundle_total_price() returns total bundle price. Shop_CartItem
get_bundle_item() returns a bundle item object this cart item refers to. Shop_CartItem
get_bundle_items() returns cart items which represent bundle items for this cart item. Shop_CartItem
get_bundle_item_product() returns a bundle item product object this cart item refers to. Shop_CartItem
get_data_field() extracts a custom data field value by the field name. Shop_CartItem
get_data_fields() returns all custom data field values assigned with the cart item. Shop_CartItem
get_master_bundle_item() returns a cart item object representing a master bundle product for this item. Shop_CartItem
get_quantity() returns item quantity for displaying on pages. Shop_CartItem
get_tax_rates() returns a list of taxes applied to the cart item. Shop_CartItem
is_bundle_item() returns TRUE if the cart item represents a bundle item. Shop_CartItem
item_description() returns the item options and extra options description. Shop_CartItem
list_uploaded_files() returns a list of files uploaded by the customer on the Product Details page. Shop_CartItem
om() returns Option Matrix product property. Shop_CartItem
options_str() returns a string, describing selected product options. Shop_CartItem
single_price() returns price of a single unit of the cart item, taking into account extra paid options. Shop_CartItem
total_depth() returns the total depth of the cart item. Shop_CartItem
total_discount() returns the cart item discount. Shop_CartItem
total_height() returns the total width of the cart item. Shop_CartItem
total_price() returns total price of the item. Shop_CartItem
total_volume() returns the total volume of the cart item. Shop_CartItem
total_weight() returns the total weight of the cart item. Shop_CartItem
total_width() returns the total width of the cart item. Shop_CartItem

Events

Event Description
shop:onGetCartItemPrice Allows to override a price of an item in the shopping cart.
shop:onUpdateCartItemPrice Allows to update a default shopping cart item price, or price returned by the shop:onGetCartItemPrice event.

Property details

cart_name property

public string $cart_name;
Specifies a name of the cart the item belongs to.

extra_options property

public array $extra_options;
An array of extra paid options, selected by a customer. Each element in the array is a PHP object with two fields: $price and $description.

key property

public string $key;
Specifies the item key. Item keys are used for identifying items in the cart.

options property

public array $options;
An array of selected product options. Each element of the array is another array with keys corresponding the option name and values corresponding the option value: array('Color'=>'Blue')

order_item property

public Shop_OrderItem $order_item;
Specifies a reference to the original order item object. This property is not empty in case if the cart item was created by converting an order item to the cart item.

postponed property

public boolean $postponed;
Determines whether the cart item is postponed.

product property

public Shop_Product $product;
A product object corresponding to the cart item.

quantity property

public integer $quantity;
Specifies the product quantity.

Method details

bundle_item_total_price() method

public Returns bundle_item_total_price()
{return} Returns the bundle item total price.
Returns total price of a bundle item cart item (total price of the bundle item in a single base product). If the cart item does not represent a bundle item product, the method returns the total_price() method result.

bundle_single_price() method

public float bundle_single_price()
{return} float returns the bundle item unit price.
Returns total price (sum if all bundle items) of a single unit of the bundle product cart item. If the cart item does not represent a bundle product, the method returns the single_price() method result.

bundle_total_discount() method

public float bundle_total_discount()
{return} float returns total discount of a single item of the bundle product cart item.
Returns total discount of a single item of the bundle product cart item. If the cart item does not represent a bundle product, the method returns the total_discount() method result.

bundle_total_price() method

public float bundle_total_price()
{return} float returns the bundle total price.
Returns total bundle price. The price includes the price of the base bundle products and all its bundle items. If the cart item does not represent a bundle product, the method returns the total_price() method result.

get_bundle_item() method

public Shop_ProductBundleItem get_bundle_item()
{return} Shop_ProductBundleItem returns the bundle item object or NULL.
Returns a bundle item object this cart item refers to. If this cart item does not represent a bundle item product, returns NULL.

get_bundle_items() method

public Returns get_bundle_items()
{return} Returns an array of Shop_CartItem objects.
Returns cart items which represent bundle items for this cart item.

get_bundle_item_product() method

public Shop_BundleItemProduct get_bundle_item_product()
{return} Shop_BundleItemProduct returns bundle item product object or NULL.
Returns a bundle item product object this cart item refers to. If this item does not represent a bundle item product, returns NULL.

get_data_field() method

public Returns get_data_field(string $field_name, mixed $default=NULL)
$field_name string specifies the field name. Field names should start with x_ prefix.
$default mixed specifies a default field value to return if the field is not found.
{return} Returns the custom data field value or the default value.
Extracts a custom data field value by the field name. Use this field for displaying custom data fields previously assigned to the cart items. Controls for custom data fields should have names in the following format: item_data[item_key][field_name]. You can read about creating custom per-item input fields on the Cart page in this article. Example:
<textarea 
  name="item_data[<?= $item->key ?>][x_engraving_text]"><?= h($item->get_data_field('x_engraving_text')) ?></textarea>

get_data_fields() method

public array get_data_fields()
{return} array returns an associative array of custom field names and values.
Returns all custom data field values assigned with the cart item.

get_master_bundle_item() method

public Shop_CartItem get_master_bundle_item()
{return} Shop_CartItem returns the cart item object or NULL.
Returns a cart item object representing a master bundle product for this item. The result value could be NULL in case if the item is not a bundle item or if the master cart item cannot be found.

get_quantity() method

public Returns get_quantity()
{return} Returns the item quantity.
Returns item quantity for displaying on pages. For regular items returns the total quantity of the item in the cart. For bundle items returns the quantity of the item in the parent bundle. For example, if there was a computer bundle product in the cart and its quantity was 2 and it had a bundle item CPU with quantity 2, the actual quantity for CPU would be 4, while the visible quantity, returned by this method, would be 2.

get_tax_rates() method

public array get_tax_rates()
{return} array returns an array of objects with name and rate fields.
Returns a list of taxes applied to the cart item. The method returns an array, containing objects with the following fields: name, rate. You can use this method to output a list of applied taxes in the cart item table. Example:
<? foreach ($item->get_tax_rates() as $tax_info): ?>
  <?= h($tax_info->name) ?>
<? endforeach ?>

is_bundle_item() method

public boolean is_bundle_item()
{return} boolean returns TRUE if the cart item represents a cart item. Returns FALSE otherwise.
Returns TRUE if the cart item represents a bundle item.

item_description() method

public Returns item_description(string $options_delimiter='; ', boolean $lowercase_options=true, boolean $as_html=true)
$options_delimiter string specifies a delimiter string for options.
$lowercase_options boolean convert options values to lower case.
$as_html boolean determines whether the result string should be converted to HTML.
{return} Returns hTML string describing the item options and extra options.
Returns the item options and extra options description. This method simplifies front-end coding.

list_uploaded_files() method

public array list_uploaded_files()
{return} array returns an array of objects with name, size and path fields.
Returns a list of files uploaded by the customer on the Product Details page. Use this method to display files assigned with items on the Cart page. The method returns an array of arrays with the following keys: name, size, path.

om() method

public mixed om(string $property_name)
$property_name string specifies the property name.
{return} mixed returns the property value or NULL.
Returns Option Matrix product property. If Option Matrix product is not associated with the cart item, returns property value of the base product. Specify the property name in the first parameter. Use the method on the Cart page to output Option Matrix specific parameters, for example product images. The following example outputs a product image in the cart 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 ?>

options_str() method

public string options_str(string $delimiter='; ', boolean $lowercase_values=false)
$delimiter string specifies a delimiter string.
$lowercase_values boolean convert option values to lower case.
{return} string returns the item options description.
Returns a string, describing selected product options. The returned string has the following format: Color: white; Size: M. Use this method to simplify the code for displaying the shopping cart content.

single_price() method

public float single_price(boolean $include_extras=true)
$include_extras boolean specifies whether extra options price should be included to the result.
{return} float returns the item price.
Returns price of a single unit of the cart item, taking into account extra paid options. The discount value is not subtracted from the single price. Behavior of this method can be altered by shop:onGetCartItemPrice and shop:onUpdateCartItemPrice event handlers.

total_depth() method

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

total_discount() method

public float total_discount()
{return} float returns the item discount.
Returns the cart item discount.

total_height() method

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

total_price() method

public float total_price(boolean $apply_catalog_price_rules=true, boolean $force_tax=false, integer $quantity=NULL)
$apply_catalog_price_rules boolean determines whether catalog price rules should be applied to the result, true by default.
$force_tax boolean determines whether taxes should be added to the result, overriding Display catalog/cart prices including tax option status.
$quantity integer specifies the item quantity. If this parameter is omitted, the internal value is used.
{return} float returns the item total price.
Returns total price of the item. The method takes into account the item quantity, extra options and discounts value. Adds tax to the result if the Display catalog/cart prices including tax option is enabled or $force_tax parameter is TRUE.

total_volume() method

public float total_volume()
{return} float returns the item total volume.
Returns the total volume of the cart 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 cart 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 cart item. The total depth is unit depth * quantity.