-
-
Save bekarice/243a35fbab62ff546632 to your computer and use it in GitHub Desktop.
Venture theme: Templates > cart.liquid changes (Pro) -- the unminified version of the script at the bottom of this file can be viewed here: https://gist.github.com/bekarice/664883cb8e4b5568a8b2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if cart.item_count > 0 %} | |
<h1 class="small--text-center">{{ 'cart.general.title' | t }}</h1> | |
<form action="/cart" method="post" novalidate class="cart"> | |
<table class="responsive-table cart-table"> | |
<thead class="cart__row visually-hidden"> | |
<th colspan="2">{{ 'cart.label.product' | t }}</th> | |
<th>{{ 'cart.label.quantity' | t }}</th> | |
<th>{{ 'cart.label.total' | t }}</th> | |
</thead> | |
<tbody id="CartProducts"> | |
{% for item in cart.items %} | |
- <tr class="cart__row responsive-table__row"> | |
+ <tr class="cart__row responsive-table__row" style="{% include 'product-customizer-helper' with 'hide-pricing-item-row' %}" {% include 'product-customizer-helper' with 'cart-row-data' %}> | |
<td class="cart__cell--image text-center"> | |
<a href="{{ item.url | within: collections.all }}" class="cart__image"> | |
<img src="{{ item | img_url: 'medium' }}" alt="{{ item.title | escape }}"> | |
</a> | |
</td> | |
<td> | |
<a href="{{ item.url }}" class="h5"> | |
{{ item.product.title }} | |
</a> | |
{% unless item.variant.title contains 'Default' %} | |
<p>{{ item.variant.title }}</p> | |
{% endunless %} | |
{% if settings.product_vendor_enable %} | |
<p>{{ item.vendor }}</p> | |
{% endif %} | |
+ {% include 'product-customizer-helper' %} | |
{% comment %} | |
Optional, loop through custom product line items if available | |
Line item properties come in as having two parts. The first part will be passed with the default form, | |
but p.last is the actual custom property and may be blank. If it is, don't show it. | |
For more info on line item properties, visit: | |
- http://docs.shopify.com/support/your-store/products/how-do-I-collect-additional-information-on-the-product-page-Like-for-a-monogram-engraving-or-customization | |
- {% endcomment %} | |
{% assign property_size = item.properties | size %} | |
{% if property_size > 0 %} | |
{% for p in item.properties %} | |
{% unless p.last == blank %} | |
{{ p.first }}: | |
{% comment %} | |
Check if there was an uploaded file associated | |
{% endcomment %} | |
{% if p.last contains '/uploads/' %} | |
<a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a> | |
{% else %} | |
{{ p.last }} | |
{% endif %} | |
{% endunless %} | |
{% endfor %} | |
{% endif %} | |
+ <!-- removed for Product Customizer support --> {% endcomment %} | |
+ <br /><a href="{% include 'product-customizer-helper' with 'remove-from-cart-href' %}" class="cart {% include 'product-customizer-helper' with 'remove-from-cart-class' %}">Remove</a> | |
</td> | |
<td class="cart__cell--quantity"> | |
<label for="Updates_{{ item.id }}" class="cart__quantity-label medium-up--hide">{{ 'cart.label.quantity' | t }}</label> | |
<input type="number" name="updates[]" id="Updates_{{ item.id }}" class="cart__quantity" value="{{ item.quantity }}" min="0" data-line="{{ forloop.index }}"> | |
</td> | |
<td class="cart__cell--total"> | |
<span class="cart__item-total"> | |
- {{ item.line_price | money }} | |
+ {% include 'product-customizer-helper' with 'item-line-price', items: cart.items %} | |
</span> | |
</td> | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
...(REST OF CART TEMPLATE FILE) | |
(add these two lines at the very bottom of the file:) | |
+ {% include 'product-customizer-helper' with 'product-customizer-script' %} | |
+ <script> (function() { function asyncLoad() { QtySelector.prototype.updateItemQuantity = function (line, quantity) { var refreshPage = false; var $row = $('[data-product-customizer-pricing-ref][data-product-customizer-pricing-qty][data-line="' + line + '"]'); if ($row.length > 0) { var pricingRef = $row.data('product-customizer-pricing-ref'); var pricingItemQuantity = $row.data('product-customizer-pricing-qty'); var $pricingItemRow = $row.siblings('[data-product-customizer-pricing-ref=' + pricingRef + ']'); if ($pricingItemRow.length > 0) { $.ajax({ method: 'POST', url: '/cart/change.js', data: 'quantity=' + (quantity * pricingItemQuantity) + '&line=' + $pricingItemRow.data('line'), async: false }); } } if ($('form[action="/cart"]').find('[data-product-customizer-pricing-ref]').length > 0 && !$('form[action="/cart"]').prop('data-doing-submit')) { refreshPage = true; } var params = { type: 'POST', url: '/cart/change.js', data: 'quantity=' + quantity + '&line=' + line, dataType: 'json', success: $.proxy(function(cart) { if (refreshPage) { location.reload(); } else { this.updateCartItemCallback(cart); } }, this) }; $.ajax(params); }; } window.attachEvent ? window.attachEvent('onload', asyncLoad) : window.addEventListener('load', asyncLoad, false); })(); </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment