Last Edited: Oct 24, 2019
-You have completed How to Create a Shopping Cart and Guest Checkout
Cart layouts are stored in the following structure:
The wrapper.liquid file should contain the code for the main section of code that wraps around the loop of Products in the Cart. It should include the following liquid to insert the loop of Products:
It should also contain the controls required for the Cart as a whole. You can add the following buttons:
If you have added Product Attributes to the Products in the Siteglide Admin, you can also access the cart_product_attributes object with the following liquid:
Normally though, Attributes will be handled in the next step- the item.liquid file.
The item.liquid file should contain the code which is rendered for each iteration of the loop of Products. Building the Cart's item.liquid file is similar to building an item.liquid layout file for a Product List View. Learn more about the available fields here.
There are some additional points to bear in mind when creating a cart layout's item.liquid file:
In order to make sure Users do not increase the quantity of items in their Cart, when the Product is out of stock, you could use a simple if statement:
To improve this so that the User cannot increase the value by a greater number than is allowed by the stock level, you could add a "max" attribute to the quantity input:
See the Product Layout Reference Doc for fields you can use throughout your Product Layouts.