Tokens are small bits of code that let you integrate LightCMS's dynamic content management functionality with your website designs.  This section provides detailed information about our tokens and how to utilize them.

Shopping Cart Status


Token
<$shoppingcartstatus$>
    <$cartfull$>content<$/cartfull$>
    <$cartempty$>content<$/cartempty$>
<$/shoppingcartstatus$>
Purpose This token inserts custom HTML content into the markup based on whether or not the site's shopping cart contains any items. The markup generated by the token can be customized with several variables and one function. This token is used to provide the user insight into the state of their shopping cart and a link to visit their cart in order to checkout.
Attributes
  • cssClass= used to specify a CSS class for the token. The class is attached to a <div> that contains the markup output by the token.
Special Notes
  • You do not have to include both the cartfull state and the cartempty state. If you leave a state off, that state's default configuration will be used (see "Default Usage" below).
  • You can utilize content variables (see below) to customize the content that is output.
  • You can utilize the pluralize function (see below) to create a switch based on the singular or plural state of a variable.
  • You can insert any amount of HTML content into these states.
  • You cannot use other tokens inside the content areas of this token.
Variables

The following variables can be inserted into the cartfull or cartempty states to customize the content.

  • cart.item_total - the number of items currently in the cart.
  • cart.money_total - the total value of all items currently in the cart.
  • cart.weight_total - the weight of all items currently in the cart.
  • cart.url - the url to the site's shopping cart page.
  • checkout.url - the URL to the site's checkout page
Functions

The following function can be inserted into the cartfull or cartempty states to customize the content.

  • pluralize(num, 'singleState', 'pluralState') - creates a switch that allows you to adjust content based on whether a value is singular or plural.
    • num (required) - the value you want to evaluate (such as cart.item_total)
    • singleState (required) - the content you want to use if num is 1
    • pluralState (optional) - the content you want to use if num is greater than 1. If pluralState is undefined, the function will intelligently attempt to pluralize the singleState word and output the result.
Example Usage
Use this token to create an area on your site that shows how many items are in the user's cart, the total value of items in the cart and provides links to view the cart or checkout. If there are no items in the cart, a simple message is displayed.
  • <$shoppingcartstatus cssClass="my-shopping-cart"$>
    • <$cartfull$>
      • <span class="cart-items">There [pluralize(cart.item_total, 'is', 'are')] [cart.item_total] [pluralize(cart.item_total, 'item', 'items')] in your cart.</span>
      • <span id="cart-total">Total: [cart.money_total]</span>
      • <a class="cart-link" href="[cart.url]">view cart</a> or <a class="checkout-link" href="[checkout.url]">checkout</a>
    • <$/cartfull$>
    • <$cartempty$>
      • <span class="cart-items">Your cart is empty.</span>
    • <$/cartempty$>
  • <$/shoppingcartstatus$>
Default Usage
This token provides a shortcut method for implementing the default shopping cart status configuration. If you wish to implement the default configuration (see below), you can do so easily by simply using the following token:

<$shoppingcartstatus/$>

You may add your own cssClass attribute to this shortcut method if needed as well.

The default configuration for an individual state will also be used if that state is not specified in the token. For example, if you use the token but only include custom content for the "cartfull" state, then the "cartempty" state will use the default configuration.

Default Configuration:
  • <$shoppingcartstatus$>
    • <$cartfull$>
      • <a href="[cart.url]">view cart</a> (<span class="itemTotal">[cart.item_total]</span> [pluralize(cart.item_total, 'item')])
    • <$/cartfull$>
    • <$cartempty$>
      • <a href="[cart.url]">view cart</a> (<span class="itemTotal">[cart.item_total]</span> [pluralize(cart.item_total, 'item')])
    • <$/cartempty$>
  • <$/shoppingcartstatus$>