Paste
Pasted as JavaScript by Jesper ( 5 years ago )
{% capture form_id %}AddToCartForm-{{ section_id }}{% endcapture %}
{% form 'product', product, id: form_id, class: 'product-single__form' %}
{% unless product.has_only_default_variant %}
{%- for option in product.options_with_values -%}
{%- if settings.product_color_swatches -%}
{%- assign is_color = false -%}
{%- assign color_option_index = 0 -%}
{%- assign swatch_trigger = 'products.general.color_swatch_trigger' | t | downcase-%}
{%- assign color_option_index = forloop.index0 -%}
{%- assign downcased_option = option.name | downcase -%}
{%- if downcased_option contains swatch_trigger -%}
{%- assign is_color = true -%}
{%- elsif swatch_trigger == 'color' and downcased_option contains 'colour' -%}
{%- assign is_color = true -%}
{%- endif -%}
{%- endif -%}
{% if settings.variant_type == 'button' %}
{% render 'variant-button',
section_id: section_id,
option: option,
forloop: forloop,
is_color: is_color,
color_option_index: color_option_index
%}
{% else %}
{% render 'variant-dropdown',
section_id: section_id,
option: option,
forloop: forloop
%}
{% endif %}
{%- endfor -%}
{% endunless %}
<select name="id" id="ProductSelect-{{ section_id }}" class="product-single__variants no-js">
{% for variant in product.variants %}
{% if variant.available %}
<option {% if variant == product.selected_or_first_available_variant %}
selected="selected" {% endif %}
value="{{ variant.id }}">
{{ variant.title }} - {{ variant.price | money_with_currency }}
</option>
{% else %}
<option disabled="disabled">
{{ variant.title }} - {{ 'products.product.sold_out' | t }}
</option>
{% endif %}
{% endfor %}
</select>
{% if settings.quantity_enable %}
<div class="product__quantity product__quantity--{{ settings.variant_type }}">
<label for="Quantity-{{ section_id }}">{{ 'products.product.quantity' | t }}</label>
{% render 'quantity-input', id: section_id, qty: 1, min: 1 %}
</div>
{% endif %}
{%- assign inventory_visible = false -%}
{%- if settings.inventory_enable and current_variant.inventory_management == 'shopify' -%}
{%- if current_variant.inventory_quantity <= settings.inventory_threshold and current_variant.inventory_quantity >= 0 -%}
{%- assign inventory_visible = true -%}
{%- endif -%}
{%- endif -%}
{%- if current_variant.inventory_quantity == 0 or current_variant.inventory_policy == 'continue' -%}
{%- assign inventory_visible = false -%}
{%- endif -%}
{%- if settings.inventory_enable -%}
<div
id="ProductInventory-{{ section_id }}"
class="product__inventory {% unless inventory_visible %}hide{% endunless %}"
>
{% if current_variant.available %}
{{ 'products.product.stock_label' | t: count: current_variant.inventory_quantity }}
{% endif %}
</div>
{%- endif -%}
{%- if settings.inventory_transfers_enable -%}
<div
id="ProductIncomingInventory-{{ section_id }}"
class="product__inventory{% if inventory_visible %} hide{% endif %}">
{%- if current_variant.incoming and inventory_visible == false -%}
{%- if current_variant.next_incoming_date -%}
{% assign date = current_variant.next_incoming_date | date: format: 'date' %}
{%- if current_variant.available -%}
{{ 'products.product.will_not_ship_until' | t: date: date }}
{%- else -%}
{{ 'products.product.will_be_in_stock_after' | t: date: date }}
{%- endif -%}
{%- else -%}
{{ 'products.product.waiting_for_stock' | t }}
{%- endif -%}
{%- endif -%}
</div>
{%- endif -%}
{%- assign enable_dynamic_buttons = false -%}
{% if settings.enable_payment_button and template != 'product.preorder' %}
{%- assign enable_dynamic_buttons = true -%}
{% endif %}
{% if enable_dynamic_buttons %}
<div class="payment-buttons">
{% endif %}
{%- assign default_text = 'products.product.add_to_cart' | t -%}
{%- assign button_text = 'products.product.add_to_cart' | t -%}
{%- if current_variant.available -%}
{%- if template == 'product.preorder' -%}
{%- assign default_text = 'products.product.add_to_cart' | t -%}
{%- assign button_text = 'products.product.preorder' | t -%}
{%- endif -%}
{%- else -%}
{%- assign button_text = 'products.product.sold_out' | t -%}
{%- endif -%}
<button>
{% if product.empty? %}type="button"{% else %}type="submit"{% endif %}
name="add"
id="AddToCart-{{ section_id }}"
class="btn btn--full add-to-cart {% if enable_dynamic_buttons %} btn--secondary{% endif %}"
{% unless current_variant.available %} disabled="disabled"{% endunless %}>
<span id="AddToCartText-{{ section_id }}" data-default-text="{{ default_text }}" >
{{ button_text }} {{ current_variant.price | money }}
</span>
</button>
{% if enable_dynamic_buttons %}
{{ form | payment_button }}
{% endif %}
{% if enable_dynamic_buttons %}
</div>
{% endif %}
<textarea id="VariantsJson-{{ section_id }}" class="hide" aria-hidden="true">
{{ product.variants | json }}
</textarea>
{% if product.options.size > 1 %}
<textarea id="CurrentVariantJson-{{ section_id }}" class="hide" aria-hidden="true">
{{ current_variant | json }}
</textarea>
{% endif %}
<!-- Spice Product Addons Snippet Starts -->
<div id="spiceaddonsappid">{% assign product_collections = product.collections | map: "id" %}{% if product_collections %}<input type="hidden" id="sgcollections" value="{{ product_collections | join: ',' }}"/>{% endif %}</div>
<!-- Spice Product Addons Snippet ends -->
{% endform %}
Revise this Paste