Hello.
I have fixed it so that it shows the first available variant instead of the lowest price.
If I then have offers for all variants, then it takes the price of the offer from the lowest price and not the first variant that is in stock.
Hope you can help.
Here is the code
PRODUCT CASE (used on card)
{%- endcomment -%}
{%- if product.price_varies and product.compare_at_price -%}
{%- assign cheapest_variant = product.variants | sort: ‘price’ | first -%}
{%- capture price_min -%}
{%- if settings.currency_code_enabled -%}
{{- cheapest_variant.price | money_with_currency -}}
{%- else -%}
{{ product.selected_or_first_available_variant.price | money }}
{%- endif -%}
{%- endcapture -%}
{%- if cheapest_variant.price < cheapest_variant.compare_at_price -%}
{{ ‘product.price.sale_price’ | t }}
{{- ‘product.price.from_price_html’ | t: price_min: price_min -}}
{%- if settings.currency_code_enabled -%}
{{- cheapest_variant.compare_at_price | money_with_currency -}}
{%- else -%}
{{- cheapest_variant.compare_at_price | money -}}
{%- endif -%}
{%- else -%}
{{ ‘product.price.sale_price’ | t }}
{{- ‘product.price.from_price_html’ | t: price_min: price_min -}}
{%- endif -%}
{%- elsif product.price < product.compare_at_price -%}
{{ ‘product.price.sale_price’ | t }}
{%- if settings.currency_code_enabled -%}
{{- product.price | money_with_currency -}}
{%- else -%}
{{- product.price | money -}}
{%- endif -%}
{%- if settings.currency_code_enabled -%}
{{- product.compare_at_price | money_with_currency -}}
{%- else -%}
{{- product.compare_at_price | money -}}
{%- endif -%}
{%- elsif product.price_varies -%}
{%- capture price_min -%}
{%- if settings.currency_code_enabled -%}
{{ product.price_min | money_with_currency }}
{%- else -%}
{{ product.price_min | money }}
{%- endif -%}
{%- endcapture -%}
{%- capture price_max -%}
{%- if settings.currency_code_enabled -%}
{{- product.price_max | money_with_currency -}}
{%- else -%}
{{- product.price_max | money -}}
{%- endif -%}
{%- endcapture -%}
{%- if settings.currency_code_enabled -%}
{{- product.price | money_with_currency -}}
{%- else -%}
{{- product.price | money -}}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- unless hide_unit_price -%}
{%- assign unit_price_item = variant | default: line_item | default: product.selected_or_first_available_variant -%}
{%- if unit_price_item.unit_price or form_id != blank -%}
<unit-price {% if form_id %}form=“{{ form_id }}”{% endif %} {% unless unit_price_item.unit_price %}hidden{% endunless %} class=“{{ unit_price_classes }}”>
{%- assign unit_price_measurement = unit_price_item.unit_price_measurement -%}
{%- if unit_price_measurement.reference_value != 1 -%}
{%- assign reference_value = unit_price_measurement.reference_value -%}
{%- endif -%}
({{ unit_price_item.unit_price | money }}/{{ reference_value }}{{ unit_price_measurement.reference_unit }})
{%- endif -%}
{%- endunless -%}