Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am trying to add the the image url as a data attribute so that I can use it for Java Script, however it the data it gives me is not the variant image url. In the below code you would be looking at where it says 'data-image-url', I would apprecaite any help.
<form action="/cart/add" method="post" enctype="multipart/form-data" id="AddToCartForm" class="product-form">
{% unless product.has_only_default_variant %}
{% for option in product.options_with_values %}
<label {% if option.name == 'default' %}class="label--hidden" {% endif %}for="{{ section.id }}-{{ option.position }}-{{ forloop.index0 }}">
{{ option.name }}
</label>
{% assign option_position = forloop.index %}
<fieldset>
{%- for value in option.values -%}
<input type="radio" class="single-option-selector-{{ section.id }} "
{% if option.selected_value == value %} checked="checked"{% endif %}
value="{{ value | escape }}"
data-index="option{{option_position}}"
name="{{ option.name | handleize }}"
id="{{ section.id }}-{{ option.position }}-{{ forloop.index0 }}"
data-image-url="{{ variant.featured_image | img_url: 'small' }}">
<label for="{{ section.id }}-{{ option.position }}-{{ forloop.index0 }}">
{{value}}
</label>
{%- endfor -%}
</fieldset>
{% endfor %}
{% endunless %}
{{ current_variant.price | money }}
<label for="Quantity">quantity</label>
<input type="number" id="Quantity" name="quantity" value="1" min="1">
<button type="submit" name="add" id="AddToCart">Add to cart</button>
</form>
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024