Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (46 sloc) 2.36 KB
{#
https://docs.snipcart.com/configuration/product-definition
@todo set max quantity to inventory amount
#}
{%- set price = fieldData.price -%}
{% if templateParams.price is defined and templateParams.price is not empty -%}
{% set price = templateParams.price is iterable ?
(templateParams.price | json_encode) :
templateParams.price
-%}
{% endif -%}
{% set classes = templateParams.classes ?? [] -%}
<a href="{{ templateParams.href }}"
class="snipcart-add-item{% if classes | length %} {{ classes | join(' ') }}{% endif %}"
{% if templateParams.target %}target="{{ templateParams.target }}"{% endif %}
{% if templateParams.title %}title="{{ templateParams.title|t }}"{% endif %}
{% if templateParams.rel %}rel="{{ templateParams.rel }}"{% endif %}
{% if templateParams.image %}data-item-image="{{ templateParams.image }}"{% endif %}
data-item-id="{{ fieldData.sku }}"
data-item-name="{{ fieldData.element.title }}"
data-item-price='{{ price | raw }}'
data-item-url="{{ fieldData.element.url }}"
data-item-quantity="{{ templateParams.quantity }}"
data-item-taxable="{{ fieldData.taxable ? 'true' : 'false' }}"
data-item-shippable="{{ fieldData.shippable ? 'true' : 'false' }}"
{%- if fieldData.shippable %}
data-item-width="{{ fieldData.getDimensionInCentimeters('width') | round(0, 'ceil') }}"
data-item-length="{{ fieldData.getDimensionInCentimeters('length') | round(0, 'ceil') }}"
data-item-height="{{ fieldData.getDimensionInCentimeters('height') | round(0, 'ceil') }}"
data-item-weight="{{ fieldData.getWeightInGrams() }}"
{% endif -%}
{%- if templateParams.additionalProps is defined and templateParams.additionalProps | length %}
{% for property, value in templateParams.additionalProps %}
{{ property }}="{{ value }}"
{%- endfor %}
{%- endif %}
{%- for customOption in templateParams.customOptions -%}
data-item-custom{{ loop.index }}-name="{{ customOption.name }}"
data-item-custom{{ loop.index }}-required="{{ customOption.required ? 'true' : 'false' }}"
data-item-custom{{ loop.index }}-options="{% for option in customOption.options -%}
{{ option.name }}[{{ '+' not in option.price and option.price >= 0 ? '+' : '' }}{{ option.price }}]
{%- if not loop.last %}|{% endif %}{% endfor %}"
{%- endfor -%}
>
{{- templateParams.text|t -}}
</a>
You can’t perform that action at this time.