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

Defined in /modules/shop/classes/shop_checkoutdata.php, lines 13-1083
Author LemonStand eCommerce Inc.
Contains information collected during the checkout process. The class acts as an internal checkout data storage. It has methods for setting and loading the checkout information, along with a method for placing a new order. It allows to implement custom checkout scenarios. The default actions use this class internally.

See Also

Public methods

Method Description Defined By
calculate_totals() returns checkout totals information. Shop_CheckoutData
copy_billing_to_shipping() copies the billing address information into the shipping address information. Shop_CheckoutData
display_prices_incl_tax() determines whether prices should be displayed with taxes included. Shop_CheckoutData
flatten_shipping_options() converts multi-option shipping options to single-option options. Shop_CheckoutData
get_billing_info() returns the billing address information. Shop_CheckoutData
get_cart_id() returns the shopping cart content identifier saved in the beginning of the checkout process. Shop_CheckoutData
get_coupon_code() returns a coupon code previously set with set_coupon_code() method. Shop_CheckoutData
get_customer_notes() returns the customer notes string previously set with set_customer_notes() method. Shop_CheckoutData
get_payment_method() returns a payment method information previously set with set_payment_method() method. Shop_CheckoutData
get_shipping_info() returns the shipping address information. Shop_CheckoutData
get_shipping_method() returns a shipping method information previously set with set_shipping_method() method. Shop_CheckoutData
list_available_shipping_options() returns a list of available shipping methods. Shop_CheckoutData
load_from_customer() loads shipping and billing address information from a customer object. Shop_CheckoutData
place_order() creates a new order order. Shop_CheckoutData
reset_all() removes any checkout data from the session. Shop_CheckoutData
reset_shipping_method() deletes the shipping method information from the checkout data. Shop_CheckoutData
set_billing_info() sets billing address information from POST fields or from Shop_CheckoutAddressInfo object. Shop_CheckoutData
set_coupon_code() sets a specific coupon code. Shop_CheckoutData
set_customer_notes() sets customer notes string. Shop_CheckoutData
set_payment_method() sets a payment method. Shop_CheckoutData
set_shipping_info() sets shipping address information from POST fields or from Shop_CheckoutAddressInfo object. Shop_CheckoutData
set_shipping_location() sets shipping country, state and ZIP/postal code. Shop_CheckoutData
set_shipping_method() sets a shipping method. Shop_CheckoutData
shipping_required() determines whether the shopping cart contains any shippable items. Shop_CheckoutData

Method details

calculate_totals() method

public static mixed calculate_totals(string $cart_name='main')
$cart_name string specifies the cart name.
{return} mixed returns an object.
Returns checkout totals information. The information is calculated basing on the checkout data set with set_billing_info(), set_shipping_info(), set_shipping_method(), set_payment_method() methods or basing on default values if possible. The method returns an object with the following fields:
  • all_taxes - an array of all taxes applied to products and shipping. Each element is an object with two fields: name and total.
  • discount - the applied discount value.
  • discount_tax_incl - the applied discount value with tax included.
  • free_shipping - determines whether free shipping was applied by the Discount Engine.
  • goods_tax - total amount of sales taxes applied to the products.
  • product_taxes - an array of sales taxes applied to products. Each element is an object with two fields: name and total.
  • shipping_quote - specifies the shipping quote.
  • shipping_quote_tax_incl - specifies the shipping quote with the shipping tax applied.
  • shipping_tax - specifies the shipping tax amount.
  • shipping_taxes - an array of shipping. Each element is an object with two fields: name and total.
  • subtotal - subtotal amount with no discounts applied.
  • subtotal_discounts - subtotal amount with discounts applied.
  • subtotal_tax_incl - subtotal amount with discounts and taxes applied.
  • total - total amount.
  • copy_billing_to_shipping() method

    public static void copy_billing_to_shipping()
    Copies the billing address information into the shipping address information.

    display_prices_incl_tax() method

    public static boolean display_prices_incl_tax(Shop_Order $order=NULL)
    $order Shop_Order specifies an optional order object to load the customer information from.
    {return} boolean returns TRUE if prices should be displayed with taxes included. Returns FALSE otherwise.
    Determines whether prices should be displayed with taxes included. Use this method to determine whether prices should be displayed with tax included in tax inclusive environments. By default the method loads the customer's location from the currently logged in customer, but if the $order parameter is provided, the customer data is loaded from that object.

    flatten_shipping_options() method

    public static array flatten_shipping_options(array $shipping_options)
    $shipping_options array specifies the shipping option list to flatten.
    {return} array returns an array of flat shipping options.
    Converts multi-option shipping options to single-option options. Flat shipping option lists simplify front-end coding.

    get_billing_info() method

    public static Shop_CheckoutAddressInfo get_billing_info()
    {return} Shop_CheckoutAddressInfo returns the checkout address info object.
    Returns the billing address information. If the billing address information is not set in the checkout data, it can be loaded from the default shipping location.

    get_cart_id() method

    public static string get_cart_id()
    {return} string returns the cart content identifier.
    Returns the shopping cart content identifier saved in the beginning of the checkout process. Comparing the result of this method with the result of the Shop_Cart::get_content_id() allows to recognize whether the shopping cart content was changed during the checkout process.

    get_coupon_code() method

    public static string get_coupon_code()
    {return} string returns the coupon code.
    Returns a coupon code previously set with set_coupon_code() method.

    get_customer_notes() method

    public static string get_customer_notes()
    {return} string returns the customer notes string
    Returns the customer notes string previously set with set_customer_notes() method.

    get_payment_method() method

    public static mixed get_payment_method()
    {return} mixed returns an object with id, name and ls_api_code fields.
    Returns a payment method information previously set with set_payment_method() method. The method returns an object with the following fields:
    • id - specifies the payment method identifier.
    • name - specifies the payment method name.
    • ls_api_code - specifies the payment method API code.
    If the payment method has not been set yet, the object's fields are empty.

    get_shipping_info() method

    public static Shop_CheckoutAddressInfo get_shipping_info()
    {return} Shop_CheckoutAddressInfo returns the checkout address info object.
    Returns the shipping address information. If the shipping address information is not set in the checkout data, it can be loaded from the default shipping location.

    get_shipping_method() method

    public static mixed get_shipping_method()
    {return} mixed returns an object.
    Returns a shipping method information previously set with set_shipping_method() method. The method returns an object with the following fields:
    • id - specifies the shipping method identifier.
    • sub_option_id - specifies the shipping method specific sub-option identifier (for multi-option shipping methods).
    • name - specifies the shipping method name.
    • sub_option_name - specifies the shipping sub-option name.
    • ls_api_code - specifies the shipping method API code.
    • quote - specifies the shipping quote.
    • quote_no_tax - specifies the shipping quote without the shipping tax applied.
    • quote_tax_incl - specifies the shipping quote with the shipping tax applied.
    • is_free - determines the shipping option is free.
    • internal_id - specifies the internal shipping method identifier, which includes both shipping method identifier and shipping sub-option identifier, for example 2_9b6fd8f11e836e9c3aceb8933d7a710b.
    If the shipping method has not been set yet, the object's fields are empty.

    list_available_shipping_options() method

    public static array list_available_shipping_options(Shop_Customer $customer, string $cart_name='main')
    $customer Shop_Customer specifies the customer object. A currently logged in customer can be loaded with Cms_Controller::get_customer().
    $cart_name string specifies the shopping cart name.
    {return} array returns an array of Shop_ShippingOption objects.
    Returns a list of available shipping methods. The list of available shipping methods is based on the customer's shipping location and the cart contents. The method returns a list of Shop_ShippingOption objects. The Shop_ShippingOption class has the following properties which are required for displaying a list of available options:
    • quote - specifies the shipping quote.
    • quote_no_tax - specifies the shipping quote without the shipping tax applied.
    • quote_tax_incl - specifies the shipping quote with the shipping tax applied.
    • sub_options - an array of the the shipping method specific sub-options.
    • multi_option - indicates whether the option has sub-options.
    • error_hint - an optional error message. This field is not empty in case if the shipping method returned an error. The content of this field can be displayed in the list of shipping methods.
    The sub_options array is not empty only for multi-option shipping methods (FedEx, USPS, etc.). Each element in the array is an object with the following fields:
    • id - specifies the sub-option identifier. Identifiers are specific for each shipping method.
    • name - specifies the sub-option name.
    • quote - specifies the sub-option shipping quote.
    • is_free - indicates whether the sub-option is free

    load_from_customer() method

    public static void load_from_customer(Shop_Customer $customer, boolean $force=false)
    $customer Shop_Customer specifies the customer object to load data from.
    $force boolean determines whether any existing data should be overridden.
    Loads shipping and billing address information from a customer object. By default this method doesn't update the address information if it has already been set in the checkout data object. Pass TRUE value to the $force parameter to override any existing data.

    place_order() method

    public static Shop_Order place_order(Shop_Customer $customer, boolean $register_customer=false, string $cart_name='main', boolean $empty_cart=true)
    $customer Shop_Customer specifies a currently logged in customer. You can load a customer object from the CMS controller: Cms_Controller::get_customer().
    $register_customer boolean determines whether a guest customer should be automatically registered (converted to a registered customer).
    $cart_name string specifies the shopping cart name to load the order item list from.
    $empty_cart boolean specifies whether the shopping cart should be emptied after the order is placed.
    {return} Shop_Order returns the order object.
    Creates a new order order. The checkout information must be prepared with set_billing_info(), set_shipping_info(), set_shipping_method(), set_payment_method() methods before this method is called.

    reset_all() method

    public static void reset_all()
    Removes any checkout data from the session.

    reset_shipping_method() method

    public static void reset_shipping_method()
    Deletes the shipping method information from the checkout data.

    set_billing_info() method

    public static void set_billing_info(Shop_Customer $customer, Shop_CheckoutAddressInfo $info=NULL)
    $customer Shop_Customer specifies a customer object. A currently logged in customer can be loaded with Cms_Controller::get_customer().
    $info Shop_CheckoutAddressInfo specifies an optional address information object to load data from.
    Sets billing address information from POST fields or from Shop_CheckoutAddressInfo object. If the $info parameter is empty, the address information is loaded from POST data using Shop_CheckoutAddressInfo::set_from_post() method. If the $info parameter is not empty, the data is loaded from it.

    set_coupon_code() method

    public static void set_coupon_code(string $code)
    $code string specifies the coupon code.
    Sets a specific coupon code. This method doesn't checks whether the coupon code exists or valid.

    set_customer_notes() method

    public static void set_customer_notes(string $notes)
    $notes string specifies the customer notes string.
    Sets customer notes string. Customer notes are saved to the order record.

    set_payment_method() method

    public static void set_payment_method(integer $payment_method_id=NULL)
    $payment_method_id integer specifies the payment method identifier.
    Sets a payment method. You can use the Shop_PaymentMethod::find_by_api_code() method for finding a specific payment method.
    Shop_CheckoutData::set_payment_method(Shop_PaymentMethod::find_by_api_code('card')->id);

    set_shipping_info() method

    public static void set_shipping_info(Shop_CheckoutAddressInfo $info=NULL)
    $info Shop_CheckoutAddressInfo specifies an optional address information object to load data from.
    Sets shipping address information from POST fields or from Shop_CheckoutAddressInfo object. If the $info parameter is empty, the address information is loaded from POST data using Shop_CheckoutAddressInfo::set_from_post() method. If the $info parameter is not empty, the data is loaded from it.

    set_shipping_location() method

    public static void set_shipping_location(integer $country_id, integer $state_id, string $zip)
    $country_id integer specifies the country identifier.
    $state_id integer specifies the state identifier.
    $zip string specifies the ZIP/postal code.
    Sets shipping country, state and ZIP/postal code. This method allows to override the shipping country, state and ZIP/postal code components of the shipping address.

    set_shipping_method() method

    public static void set_shipping_method(string $shipping_method_id=NULL, string $cart_name='main')
    $shipping_method_id string specifies the shipping method identifier.
    $cart_name string specifies the shopping cart name.
    Sets a shipping method. You can use the Shop_ShippingOption::find_by_api_code() method for finding a specific shipping method.
    Shop_CheckoutData::set_shipping_method(Shop_ShippingOption::find_by_api_code('default')->id);
    For multi-option shipping methods, like FedEx the $shipping_method_id parameter should contain both shipping method identifier and shipping method specific option identifier, separated with the underscore character, for example: 2_9b6fd8f11e836e9c3aceb8933d7a710b

    shipping_required() method

    public static boolean shipping_required(string $cart_name='main')
    $cart_name string specifies the shopping cart name
    {return} boolean returns TRUE if the cart contains any shippable items. Returns FALSE otherwise.
    Determines whether the shopping cart contains any shippable items. By default shippable items are those items which belong to the Goods product type. If the cart contains only downloadable or service-type products the method returns FALSE.