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:cart CMS action

Defined in /modules/shop/classes/shop_actions.php, lines 507-544
Author LemonStand eCommerce Inc.
Base action for the Cart page. This action can handle the shopping cart content management requests like removing items from the cart, moving items to the Postponed list and changing item quantity.

Managing content of a specific shopping cart

LemonStand supports multiple shopping carts. Using the shop:cart action you can manage a content of any specific shopping cart. All handlers and actions which work with shopping cart accept the $cart_name parameter, which specifies a name of a cart. By default LemonStand works with a shopping cart named main.
In order to display and manage a content of a specific shopping cart, need:
  1. Pass the cart_name parameter to the shop:cart action before the action is executed. You can do it using the following code on the Pre Action Code field of the Create/Edit Page form:
    $_POST['cart_name'] = 'my_second_cart';
  2. Pass the cart_name parameter to all AJAX handlers which you invoke on the Cart page. The simplest way to do it is to add a hidden field to the form which wraps your cart content:
    <input type="hidden" name="cart_name" value="my_second_cart"/>
Also the cart_name parameter should be passed to the checkout actions if you want LemonStand to create an order from a specific shopping cart items.

Supported form fields

Field Type Description
item_postponed array a checkbox-type type INPUT element, responsible for moving an item to or from the postponed items list.
item_quantity array item quantity value. Allows users to manage quantities of items in the cart.
coupon string a coupon code.
cart_name string an optional shopping cart name.

Generated PHP variables

Variable Type Description
countries Db_DataCollection a collection of countries for populating the country list for the Estimate Shipping Cost feature.
states Db_DataCollection a list of states for a currently selected country.
shipping_info Shop_CheckoutAddressInfo a customer's shipping location.
discount float a discount value, calculated using the price rules, defined on the Shop/Discounts page in the Administration Area.
applied_discount_rules array a list of discount rules applied to the cart products.
cart_total float a sum of all cart items.
subtotal float a sum of all cart items. Matches the $cart_total variable value.
cart_total_tax_incl float cart total, including tax.
cart_tax float a total tax amount for all cart items.
cart_taxes array a list of all taxes applied to the cart items.
coupon_code string a coupon code provided by the customer.

Built-in AJAX handlers

Handler Description
on_action Applies any changes on the Cart page.

Supported form field details

item_postponed form field

A checkbox-type type INPUT element, responsible for moving an item to or from the postponed items list. Example:
<input type="hidden" name="item_postponed[<?= $item->key ?>]" value="0"/>
<input type="checkbox" <?= checkbox_state($item->postponed) ?> name="item_postponed[<?= $item->key ?>]" value="1"/>
The hidden element used here to provide the default value 0 for cases when the checkbox is not checked. By default browsers do not send checkbox values if they are not checked. Please always use this method with the item_postponed checkbox.

item_quantity form field

Item quantity value. Allows users to manage quantities of items in the cart. Example:
<input type="text" name="item_quantity[<?= $item->key ?>]" value="<?= $item->quantity ?>"/>

coupon form field

A coupon code. If specified, LemonStand will apply the coupon code and re-evaluate the $discount variable

cart_name form field

An optional shopping cart name. By default all Shop module actions and AJAX handlers work with the cart named main.

Generated PHP variable details

countries variable

Db_DataCollection $countries;
A collection of countries for populating the country list for the Estimate Shipping Cost feature. Each element in the collection is an object of the Shop_Country class.

states variable

A list of states for a currently selected country. Each element in the collection is an object of the Shop_CountryState class.

shipping_info variable

Shop_CheckoutAddressInfo $shipping_info;
A customer's shipping location. For new customers all fields in the object are empty.

discount variable

float $discount;
A discount value, calculated using the price rules, defined on the Shop/Discounts page in the Administration Area. The discount value can be not accurate on the Cart page, because price rules can refer to customer details like the shipping location which are not known on the Cart page and will become available only during the checkout process.

applied_discount_rules variable

array $applied_discount_rules;
A list of discount rules applied to the cart products. Each element in the array is an object with two fields: rule (Shop_CartPriceRule object) and discount. You can use this variable for displaying a list of applied discounts. Example:
<h3>Applied discounts</h3>
<? foreach ($applied_discount_rules as $rule_info): ?>
  <p>
    <?= $rule_info->rule->name ?> 
    <?= $rule_info->rule->description ?> - 
    <?= format_currency($rule_info->discount) ?><br/>
  </p>
<? endforeach ?>

cart_total variable

float $cart_total;
A sum of all cart items.

subtotal variable

float $subtotal;
A sum of all cart items. Matches the $cart_total variable value.

cart_total_tax_incl variable

float $cart_total_tax_incl;
Cart total, including tax. If the Display catalog/cart prices including tax feature is enabled, this variable value will match the $cart_total variable value.

cart_tax variable

float $cart_tax;
A total tax amount for all cart items.

cart_taxes variable

array $cart_taxes;
A list of all taxes applied to the cart items. Each element in the array is an object with two fields: name, total.

coupon_code variable

string $coupon_code;
A coupon code provided by the customer.

Built-in AJAX handlers details

on_action AJAX handler

Applies any changes on the Cart page. The handler applies item quantities, removes items marked for removing, applies a coupon code, updates items postpone status. This handler is equal to the regular form POST method, but works through AJAX. Use this request to create the Apply Changes button on the Cart page. Example:
<input onclick="return $(this).getForm().sendRequest(
  'on_action', 
  {update: {'cart_page': 'cart_partial'}})" 
type="image" src="/resources/images/btn_apply.gif" />