Files
season/snippets/product-collection-label.liquid
T

45 lines
1.2 KiB
Plaintext

{% doc %}
Prints the category collection for a product badge.
Matches the product type to its catalog collection, such as Hidratantes or Sérum,
and skips skin labels such as Piel madura.
@param {product} product - Product whose collection is printed
@example
{% render 'product-collection-label', product: product %}
{% enddoc %}
{% liquid
assign type_handle = product.type | handleize
assign wanted = type_handle
if type_handle == 'proteccion-solar'
assign wanted = 'proteccion-solar-1'
endif
if type_handle == 'kit' or type_handle == 'kits'
assign wanted = 'kits-skincare-facial'
endif
assign label = blank
if wanted != blank
for collection_item in product.collections
if collection_item.handle == wanted
assign label = collection_item.title
break
endif
endfor
endif
if label == blank and wanted != blank
for collection_item in product.collections
if collection_item.handle contains wanted
assign label = collection_item.title
break
endif
endfor
endif
if label == blank and product.type != blank
assign label = product.type | capitalize
endif
%}
{{- label -}}