vfonic/solidify

View on GitHub
app/views/solidify/themes/skeleton-theme/templates/cart.liquid

Summary

Maintainability
Test Coverage
<h1>Shopping Cart</h1>
  
{% if cart.item_count > 0 %}

<form action="/cart" method="post">
  
  <table>
    
    <thead>
      <tr>
        <th class="hide-on-small">Item</th>
        <th>&nbsp;</th>
        <th class="hide-on-small">Price</th>
        <th>Quantity</th>
        <th>Total</th>
        <th class="hide-on-small">&nbsp;</th>
      </tr>
    </thead>
    
    <tbody>

    {% for item in cart.items %}    
    
      {% comment %}
      Determining the handle of the collection that was last seen for the 'continue shopping' link.
      {% endcomment %}
      
      {% assign collection_url = item.product.collections.last.url %}
      {% if collection_url == '/collections/frontpage' or collection_url == blank %}
        {% assign collection_url = '/collections/all' %}
      {% endif %}
      
      {% if forloop.first %}
        {% assign continue_shopping_url = collection_url %}
      {% endif %}

      <tr>
        <td class="hide-on-small">
          <a href="{{ collection_url }}{{ item.url }}">
            <img src="{{ item | img_url: 'compact' }}"  alt="{{ item.title | escape }}" />
          </a>
        </td>
        <td>
          <h2 class="delta">
            <a href="{{ collection_url }}{{ item.url }}">
            {{ item.title }}
            </a>
          </h2>
          {% comment %}
          Line Item Properties
          {% endcomment %}
          {% assign properties_amount = item.properties | size %}
          {% if properties_amount > 0 %}
          <p>
            {% for p in item.properties %}
              {% unless p.last == blank %}
                {{ p.first }}:
                {% if p.last contains '/uploads/' %}
                  <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
                {% else %}
                  {{ p.last }}
                {% endif %}
                <br />
              {% endunless %}
            {% endfor %}
          </p>
          {% endif %}
          <h3 class="epsilon">{{ item.vendor }}</h3>
        </td>
        <td class="hide-on-small">{{ item.price | money }}</td>
        <td>
          <input type="number" name="updates[]" id="updates_{{ item.id }}" class="quantity" value="{{ item.quantity }}" />
        </td>
        <td>{{ item.line_price | money }}</td>
        <td class="hide-on-small">
          <a href="/cart/change?line={{ forloop.index }}&quantity=0">Remove</a>
        </td>
      </tr>
    {% endfor %}
    
    </tbody>
    
  </table>
  
  {% comment %}
  For the checkout and update buttons to work, they need to use
  a name attribute set to 'checkout' and 'update', respectively. That's case-sensitive.
  {% endcomment %}
  
  <div class="column two-thirds flow-opposite right-aligned">
    <h3 class="gamma">Subtotal <em>{{ cart.total_price | money }}</em></h3>
    <a class="hide-on-small" href="{{ continue_shopping_url }}">Continue shopping</a>
    <span class="or hide-on-small">or</span>
    <input type="submit" name="update" value="Update cart" />
    <span class="or">or</span>
    <input type="submit" name="checkout" value="Check out" />    
    {% comment %}Paypal and Google checkout buttons{% endcomment %}
    {% if additional_checkout_buttons %}
    <p class="additional-checkout-buttons">
      {{ content_for_additional_checkout_buttons }}
    </p>
    {% endif %}
  </div>
  
  {% comment %}
  For the special instructions to be submitted with order,
  we need to use a name attribute set to 'note'.
  {% endcomment %}
  <div class="column third flow-opposite left-aligned">
    <p>Special instructions for seller</p>
    <textarea name="note">{{ cart.note }}</textarea>
  </div>

</form>

{% else %}

<div>
  <h2 class="gamma">It appears that your cart is currently empty!</h2>
  <h3 class="delta">You can continue browsing <a href="/collections/all">here</a>.</h3>
</div>

{% endif %}