|
Shop_Cart class
Represents a visitor's shopping cart.
The class has static methods for accessing the cart contents and evaluating the total price,
dimensions and weight of the cart items. Please read the Creating the Cart page article for examples of
the class usage.
All methods of this class accept the $cart_name parameter, which default value is main. You can implement multiple shopping carts with LemonStand. You can post the cart_name parameter to the shop:on_addToCart handler in order to place an item into a specific cart. By default LemonStand always work with the shopping cart named main. See AlsoPublic methods
Events
Method details¶ add_cart_item() methodpublic static Shop_CartItem add_cart_item(Shop_Product $product, array $parameters)
Adds an item to the cart.
Use this method to add new cart items programmatically. Pass an array of parameters to the second parameter.
The array can contain the following elements:
¶ add_item() methodpublic static Shop_CartItem add_item(Shop_Product $product, array $options, array $extra_options, integer $quantity, string $cart_name='main', array $custom_data=array())
This method is deprecated. Use add_cart_item() method.
Adds an item to the cart.
¶ find_by_product_sku() methodpublic static array find_by_product_sku(string $sku, string $cart_name='main')
Finds active cart items by the product SKU.
¶ find_item() methodpublic static Shop_CartItem find_item(string $key, string $cart_name='main', boolean $auto_remove_items=true)
Finds a cart item by its key.
¶ get_content_id() methodpublic static string get_content_id(string $cart_name='main')
Returns the unique cart content identifier.
The content identifier changes each time when a customer changes the cart content.
¶ get_item_total_num() methodpublic static integer get_item_total_num(string $cart_name='main', boolean $count_bundle_items=true)
Returns a total number of all active items in the shopping cart.
¶ list_active_items() methodpublic static array list_active_items(string $cart_name='main')
Returns a list of active (not postponed) cart items.
¶ list_postponed_items() methodpublic static array list_postponed_items(string $cart_name='main')
Returns a list of postponed cart items.
¶ remove_active_items() methodpublic static void remove_active_items(string $cart_name='main')
Removes all active items from the cart.
¶ remove_item() methodpublic static void remove_item(string $key, string $cart_name='main')
Returns an item from the cart.
¶ set_quantity() methodpublic static void set_quantity(string $key, integer $value, string $cart_name='main')
Sets cart item quantity.
¶ total_depth() methodpublic static float total_depth(string $cart_name='main')
Returns the total depth of active cart items.
¶ total_height() methodpublic static float total_height(string $cart_name='main')
Returns the total height of active cart items.
¶ total_price() methodpublic static float total_price(string $cart_name='main', boolean $apply_cart_discounts=true, array $items=NULL, boolean $force_tax=false)
Returns total price of all items in the cart.
Adds tax to the result if the
Display catalog/cart prices including tax
feature is enabled.
Pass FALSE value to the second parameter in order to get the cart total before discounts applied.
¶ total_price_no_tax() methodpublic static float total_price_no_tax(string $cart_name='main', boolean $apply_cart_discounts=true, array $items=NULL)
Returns total price of all items in the cart without any taxes applied.
This method is identical to total_price() method, but it
never adds tax to the result regardless of whether the
Display catalog/cart prices including tax
feature is enabled.
¶ total_tax() methodpublic static float total_tax(string $cart_name, array $items=NULL)
Returns total tax amount applied to the cart items.
¶ total_volume() methodpublic static float total_volume(string $cart_name='main')
Returns a total volume of active cart items.
¶ total_weight() methodpublic static float total_weight(string $cart_name='main')
Returns a total weight of all active items in the cart.
¶ total_width() methodpublic static float total_width(string $cart_name='main')
Returns the total width of active cart items.
|