Shopify themes, liquid, logos, and UX
Hi, I am working on my stiletto theme and I dislike the color variant option. I would love to know how to change this to fit what I want. The first picture will be what I have currently and the 2nd picture will be what I'm looking to do. Thank you!
from this (current), to the bottom style--
can you find it for me and tell me what to change? Here is a snippet of that code.
{%- comment -%}
Pass in:
- prod: object The product object
- hidden: boolean (optional, used to not trip up javascript if buy button is removed)
- price_content_type: "price" or "custom" or "hide" after checking both $0 and sold out pricing display settings
- custom_price_content: the translation to populate price if sold out or free, depending on logic checks and settings
{%- endcomment -%}
{%- liquid
assign product_available_label = 'products.product.add_to_cart' | t
assign product_unavailable_label = 'products.product.sold_out' | t
if template.suffix == 'preorder'
assign product_available_label = 'products.product.preorder' | t
endif
-%}
{%- capture form_classes -%}
product-form product-form-{{ section.id }} {% if hidden %}visually-hidden{% endif %}
{%- endcapture -%}
{% form 'product',
prod,
class: form_classes,
novalidate: 'novalidate',
data-product-form: '',
data-product-handle: prod.handle,
data-current-product-id: current_variant.id
%}
{% comment %}
product quantity within form remains hidden but will be updated
from outside the form if enabled.
{% endcomment %}
<div class="product-form__quantity">
<div class="product__label-wrapper">
<label class="product__label {{ label_classes }}" for="Quantity-Input-{{ prod.id }}">
{{ 'products.product.quantity' | t }}
</label>
</div>
<input
type="number"
id="Quantity-{{ prod.id }}"
name="quantity"
value="1"
min="1"
pattern="[0-9]*"
class="input product-form__input product-form__input--quantity"
aria-label="{{ 'general.accessibility.quantity' | t }}"
>
</div>
{% comment -%}
option field within form remains hidden but will be updated
from outside the form if enabled.
{% endcomment -%}
{% assign custom_option_blocks = blocks | where: 'type', 'custom_option' -%}
{%- for block in custom_option_blocks -%}
{%- if block.type == 'custom_option' -%}
<div class="product-form__custom-option">
<label>
{{ block.settings.label }}: 
{%- case block.settings.field_type -%}
{%- when 'text', 'textarea' -%}
<input
type="text"
class="input"
placeholder="{{ block.settings.placeholder }}"
name="properties[{{ block.settings.label }}]"
data-custom-option-target="{{ block.id }}"
>
{%- when 'checkbox' -%}
<input
type="checkbox"
value="{{ block.settings.checked_value }}"
name="properties[{{ block.settings.label }}]"
data-custom-option-target="{{ block.id }}"
>
{%- when 'list' -%}
{%- assign list_options = block.settings.list_options | split: ', ' -%}
<div class="select-wrapper">
<select
class="input"
name="properties[{{ block.settings.label }}]"
data-custom-option-target="{{ block.id }}"
>
{%- for option in list_options -%}
<option>{{ option }}</option>
{%- endfor -%}
</select>
{% render 'icon' with icon: 'chevron-small' %}
</div>
{%- endcase -%}
</label>
</div>
{%- endif -%}
{%- endfor -%}
{% comment %}
In order for this form to submit, it needs to contain an input with name="id".
ProductForm() will automatically create this input (or make sure it has the
right value set if it already exists) on form submit based on the
currently selected variant. However, if JS is disabled we need a fallback.
Include a single <select> element which allows users to select all variants
as a fallback and present it only when JS is disabled. In addition,
make sure you hide the option inputs declared above, like we do with the
`.js-enabled` class which only shows its contents when JS is enabled.
{% endcomment %}
<div class="product-form__variants">
<select
name="id"
class="input"
id="variant-selector"
data-variant-select
>
{%- for variant in prod.variants -%}
<option
value="{{ variant.id }}"
{%- if variant == current_variant -%}
selected="selected"
{%- endif -%}
>
{{ variant.title }}
{%- if variant.available == false %} - {{ 'products.product.sold_out' | t }}{% endif %}
</option>
{%- endfor -%}
</select>
</div>
{% comment -%}
With JS enabled, this form will always be hidden, but updated from an outside form.
With JS disabled, the outside form is hidden, and this form will be visible.
{% endcomment -%}
{% if section.settings.enable_gift_card_recipient and prod.gift_card? -%}
{% render 'gift-card-recipient-form', source: 'product-form', product: prod, form: form %}
{%- endif %}
<div
class="product-form__controls-group product-form__controls-group--submit"
{% if block %}
{{- block.shopify_attributes -}}
{% endif %}
>
<div
class="
product-form__item product-form__item--submit
{%- if show_dynamic_checkout %} product-form__item--payment-button {%- endif -%}
{%- if prod.has_only_default_variant %} product-form__item--no-variants {%- endif -%}
"
>
<button
type="submit"
name="add"
{% unless current_variant.available %}
aria-disabled="true" disabled
{% endunless %}
aria-label="{% unless current_variant.available %}{{ product_unavailable_label }}{% else %}{{ product_available_label }}{% endunless %}"
class="product-form__cart-submit btn btn--medium btn--full {% if show_dynamic_checkout %}btn--secondary{% else %}btn--primary{% endif %}"
data-add-to-cart
data-lang-available="{{ product_available_label }}"
data-lang-unavailable="{{ 'product.unavailable' | t }}"
data-lang-sold-out="{{ 'product.sold_out' | t }}"
>
<span data-add-to-cart-text>
{%- unless current_variant.available -%}
{{ product_unavailable_label }}
{%- else -%}
{{ product_available_label }}
{%- endunless -%}
</span>
<div class="btn__loading-wrap">
<div class="btn__loading-bar"></div>
</div>
{% render 'icon', icon: 'checkmark' %}
</button>
{%- if show_dynamic_checkout -%}
{{ form | payment_button }}
{%- endif -%}
{%- unless is_quick -%}
<div class="product-form__shop-pay fs-body-75">
{{- form | payment_terms -}}
</div>
{%- endunless -%}
{%- unless is_quick -%}
{% comment %} Surface pick-up {% endcomment %}
<div
class="store-availability-container__wrapper"
data-store-availability-container
data-base-url="{{ shop.url }}{{ routes.root_url }}"
></div>
{%- endunless -%}
</div>
</div>
{%- if block.settings.enable_sticky_atc_bar_desktop or block.settings.enable_sticky_atc_bar_mobile -%}
{% render 'sticky-atc-bar',
local_settings: block.settings,
prod: prod,
current_variant: current_variant,
featured_media: featured_media,
aspect_ratio: aspect_ratio,
price_content_type: price_content_type,
custom_price_content: custom_price_content
%}
{%- endif -%}
{%- endform -%}
Yes, how do i do that? as a contributer?
Tommy, I went ahead and did that, thank you.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024