Skip to content

Instantly share code, notes, and snippets.

@gterrill
Last active April 16, 2018 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gterrill/3ff0a886174c563fc1a4a2c62fa03a95 to your computer and use it in GitHub Desktop.
Save gterrill/3ff0a886174c563fc1a4a2c62fa03a95 to your computer and use it in GitHub Desktop.
Unriveted: cart.liquid replacement that uses regular liquid instead of rivets (kagami theme)
<div class="row">
<div id="col-main" class="col-sm-12 page-cart">
<h1 class="page-heading">Shopping Cart Summary</h1>
<div class="text-center cart-empty-wrapper" rv-show="cart.item_count | lt 1">
<p class="cart empty">{{ 'cart.general.empty' | t }}</p>
<a href="/collections/all"><i class="fa fa-long-arrow-right"></i> {{ 'cart.general.continue_shopping' | t }}</a>
</div>
<form action="/cart" method="post" id="cartform" rv-show="cart.item_count | gt 0">
<div class="cart-table">
<table>
<thead>
<tr>
<th>&nbsp;</th>
<th class="item">{{ 'cart.general.item' | t }}</th>
<th class="price">{{ 'cart.general.price' | t }}</th>
<th class="qty">{{ 'cart.general.quantity' | t }}</th>
<th class="total-price">{{ 'cart.general.total' | t }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for item in cart.items %}
<tr rv-class="item | append item.handle">
<td class="item-image">
<a href="{{ item.url }}">
<img src="{{ item.image | img_url: 'small' }}">
</a>
</td>
<td class="item-title">
<a href="{{ item.url }}">
<span class="item-name">{{ item.product.title }}</span>
</a>
<p class="item-variant">
{% unless item.variant.title == 'Default Title' %}<span class="item-variant">{{ item.variant.title }}</span>{% endunless %}
{% for p in item.properties %}
{% unless p.last == blank %}
<br/>{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
{% else %}
{{ p.last }}
{% endif %}
{% endunless %}
{% endfor %}
</p>
</td>
<td class="item-price">{{ item.price | money }}</td>
<td class="item-qty">
<div class="quantity">
<input class="replace input-cart-qty" name="updates[]" value="{{ item.quantity }}" id="updates_{{ item.id }}">
<span class="qty-wrapper">
<span class="qty-inner">
<span title="Increase" class="qty-up">
<a href="/cart/change?quantity={{ item.quantity | plus:1 }}&line={{ forloop.index }}">
<i class="fa fa-plus"></i>
</a>
</span>
<span title="Decrease" class="qty-down">
<a href="/cart/change?quantity={{ item.quantity | minus:1 }}&line={{ forloop.index }}">
<i class="fa fa-minus"></i>
</a>
</span>
</span>
</span>
</div>
</td>
<td class="item-total">{{ item.line_price | money }}</td>
<td class="action">
<a href="/cart/change?quantity=0&line={{ forloop.index }}">
<i class="fa fa-close"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div id="checkout-addnote">
<h4>{{ 'cart.general.note' | t }}</4>
<textarea id="note" rows="9" name="note">{{ cart.note }}</textarea>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="cart-right">
<div class="cart-action-wrapper">
<div class="cart-action">
<a href="/collections/all">{{ 'cart.general.continue_shopping' | t }}</a>
<button class="btn btn-default" type="submit" name="checkout">{{ 'cart.general.checkout' | t }}</button>
</div>
<div class="total-price">{{ 'cart.general.subtotal' | t }} <span rv-html="cart.total_price | money"></span></div>
<div class="note-shipping">
<span>Shipping</span>
{{ 'cart.general.note_checkout' | t }}
</div>
</div>
</div>
{% include 'shipping-calculator' %}
</div>
</div>
</form>
<script id="shipping-calculator-response-template" type="text/template">
<p id="shipping-rates-feedback" <% if (success) { %> class="success" <% } else { %> class="error" <% } %>>
<% if (success) { %>
<% if (rates.length > 1) { %>
There are <%= rates.length %> shipping rates available for <%= address %>, starting at <%= rates[0].price %>.
<% } else if (rates.length == 1) { %>
There is one shipping rate available for <%= address %>.
<% } else { %>
We do not ship to this destination.
<% } %>
<% } else { %>
<%= errorFeedback %>
<% } %>
</p>
<ul id="shipping-rates">
<% for (var i=0; i<rates.length; i++) { %>
<li><%= rates[i].name %> at <%= rates[i].price %></li>
<% } %>
</ul>
</script>
<!--[if lte IE 8]>
<style> #shipping-calculator { display: none; } </style>
<![endif]-->
{{ '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js' | script_tag }}
{{ '/services/javascripts/countries.js' | script_tag }}
{{ 'shopify_common.js' | shopify_asset_url | script_tag }}
{{ 'jquery.cart.min.js' | asset_url | script_tag }}
{% unless settings.shipping_calculator == 'Disabled' %}
<script>
Shopify.Cart.ShippingCalculator.show({
submitButton: "{{ 'cart.shipping_calculator.submit_button' | t | default: 'Calculate shipping' }}",
submitButtonDisabled: "{{ 'cart.shipping_calculator.submit_button_when_calculating' | t | default: 'Calculating...' }}"{% if customer %},
customerIsLoggedIn: true{% endif %},
moneyFormat: {{ shop.money_with_currency_format | json }}
});
</script>
{% endunless %}
</div>
</div>
@gterrill
Copy link
Author

The template has changed. Use JS instead:

{% comment %}
Hide update for BTA products
{% endcomment %}
<script>
  document.addEventListener("DOMContentLoaded", function(event) {
    var variants = [];
    {% for item in cart.items %}
      {% if item.product.metafields.bookthatapp.config %}
    variants.push({{ item.variant.id }});
      {% endif %}
    {% endfor %}
    
    for (var x = 0; x < variants.length; x++) {
      // desktop
      var row = $('tr[data-variant=' + variants[x] + ']');
      row.find('.quantity__actions').hide();
      
      var li = $('li[data-variant=' + variants[x] + ']');
      li.find('.cart-item__quantity-input').prop('readonly', true); // mobile
    }
  })
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment