Chapter 1

Cart.liquid

Almost finished the hard stuff

Cart.liquid is the page your customer will see before they go to the checkout. It lists all the products that are currently in your customer's cart

First off let's cover the case of a customer landing on this page with nothing actually in their cart.

<h1>Shopping Cart</h1>
{% if cart.item_count == 0 %}
 <!-- If the customer has nothing in their cart do this -->
  {% else %}
 <!-- If the customer does have something their cart do this -->
{% endif %}

The cart.item property keeps track of the current number of items in your customer's cart.

Now if the customer has nothing in the cart we are going to generate a few products for them to look at

...
{% if cart.item_count == 0 %}
<p>Your shopping basket is empty. Check out some of these products...</p>
<table id="gallery">
{% tablerow product in collections.frontpage.products cols: 3 limit: 12 %}
	<ul>
	  <li>
	    <a href="{{ product.url | within: collections.frontpage }}" title="{{ product.title | escape }} &mdash; {{ product.description | strip_html | truncate: 50 | escape }}"><img src="{{ product.images.first | product_img_url: 'medium' }}" alt="{{ product.title | escape }}" /></a>
	    <a href="{{ product.url | within: collections.frontpage }}">{{ product.title | truncate: 30 }}</a><br />
			<small>{{ product.price | money }}</small>
	   </li>
	</ul>
{% endtablerow %}
</table>

{% else %}
...
  1. {% tablerow product in collections.frontpage.products cols: 3 limit: 12 %} We use the {% tablerow %} logic statement. This will generate a <tr> for every product in the collection with the handle frontpage (collections.frontpage.products). cols:3 simply limits the table to 3 columns and limit:12 limits the number of products shown

Left off at cart.liquid.