CMS Actions

Actions on a page allow you to access useful variables, objects and methods to be used when building your pages. You will notice that each of the eCommerce specific pages in the system such as Cart, Category, Product and so on, all have an action set.

For example the Category page will have an action set to shop:category.

Look at the Cheat Sheet for a list of supported actions and their available variables.

To better understand actions, let's look at an example of an action and its use on the category page.

Click on the Store Design button on the sidebar and then click on the Pages link under the Editor menu. Open the Edit Page form for the Category page by clicking on the Category line item.

As demonstrated in the previous screenshot, the action for this page is set to shop:category. The shop:category action prepares the category object for use in our page code.

If you look at the URL field on the category edit page form, you will see the following pattern which builds the page URL based on the hierarchy of the category selected and is pulled from the category object.

If you look in the content section for the category page, starting on line 9, You will see the following section of code:

<div>
{% if not category %}
      <h2>Category not found</h2>
      <p>We are sorry, the requested category was not found.</p>
{% else %}
      <div> 
      {{ 
         partial('shop-product-list', {
             'products': products,
             'empty_text': 'There are no products in this category.'
          }) 
       }} 
      </div>
{% endif %}
</div>

The line we are most concerned with for our example is the section beginning on line 10:

{% if not category %}

This if not statement is referencing the category object when the page loads to determine if the category name in the URL of the page being loaded actually exists as a category in the system. If it does not exist the category not found code is outputted.

For example let's load the following URL in our store for a category that does not exist.

your-store/category/dresses

You will see that since the pets category does not exist, the category not found section of the code is outputted to the page.

However, if we navigate to the Tops category page on our website, since the Tops category exists, a list of products belonging to this category will be displayed on the page:

 

Supported Actions

ActionUsage
shop:cartExposes cart variables, product variables by item association, and checkout variables. Countries and states are also available, check out the Shipping Calculator for an idea of how to do this on the cart page.
shop:categoryExposes category variables and the product variables for products in the specific category.
shop:categoriesExposes category variables.
shop:manufacturerExposes manufacturer variables and the product variables for products by a particular manufacturer. Look at Products by Manufacturer to see an example of this.
shop:productExposes product variables for a particular product.
shop:productsExposes product variables for all products, check out how to display all products using this action.
shop:saleExposes product variables for on-sale items.
shop:checkoutExposes checkout variablescart variables, and product variables by item association. Look at the Shipping Calculator to find out how to use these countries and states.
shop:payExposes applicable payment methods for an existing payment along with order variables.
shop:updateStoredCardExposes payment methods that support stored credit cards along with customer variables. Stored cards are used when implementing subscriptions.
shop:receipt Exposes invoice variables, which include order variables and product variables by item association. See Receipt Page for examples of how to get invoice items and totals.
shop:orders Exposes order variables and customer variables for all orders.
shop:orderExposes order variables and customer variables for a particular order.
shop:search Exposes product variables associated with a particular search query.
shop:signup Allows the sign up of a customer using the shop:onSignup form ajax handler.
shop:login Allows the login of a customer using the shop:onLogin form ajax handler. Also allows sign up of a customer using the shop:onSignup form ajax handler.
shop:logout Hitting a page using this action will log out the customer.
shop:customerProfile Exposes customer variables. Countries and states are also available, check out the Shipping Calculator for an idea of how to do this on the customer profile page.
shop:passwordRestore Allows password restore form requests on pages with this action.
subscriptions:subscriptions Exposes subscription variables for all subscriptions. See Subscription CMS Actions for some good examples on using this page action. Includes customer variables.
subscriptions:subscription Exposes subscription variables for a particular subscription. See Subscription CMS Actions for some good examples on using this page action. Includes customer variables.
<paymentmethod>:checkout Adding a payment method to your store will expose these actions, for example amazonPayments:checkout. Using this page action is different for each payment method; see this list of supported payment methods to learn each implementation.
cmscontent:<action>These various CMS actions allow you to create blogs, archives, RSS feeds and much more. See CMS Actions for in-depth documentation on getting your store's content up and running.
shop:customerAddressAllows for the display and editing of a customer address. For more detail, see the Customer Address Page document.
shop:onUpdateCustomerAddressForm handler for updating a customer address. For details on supported fields, see the Customer Address Page document.
Variable Usage