Hello guys,
I have featured collection available on my home page throught theme setting and I would like to feature a specific product unstead.
I have created a collection with only that product in it and now I would like visitors to automaticaly skip collection page and be redirected to the propuct direct as theres is only one product in the collection.
Does anyone knows a workaround / plug in I can use to get that result ?
Thanks, in advance,
Mike
Hey Mike,
The forum members will need more info here before help can be offered. Consider posting things like:
You can check how many products are in a collection so in theory it will be possible to change the link from a collection directly to the single product.
I am having the same issue as taiwanspl. I have 3 featured collections on my homepage, below the slider. And each collection contains only 1 product; I would like to change that link to go directly to the product.url and not the collection.url
The code responsible for this is located within: collection-grid-item.liquid and is as follows:
<a href="{{ collections[collection_handle].url }}" class="collection-grid__item-link collection-collage__item-wrapper">
I have played around with it for a while and cannot get it to link to the products url within that collection. And yes, I have read through shopify's liquid reference tutorial on objects (https://help.shopify.com/themes/liquid/objects)
I've done a little "hack" in the sections/collection-template.liquid
When it was
{%- if section.settings.collection_products_grid == 'collage' -%}
I've insterted/changed to this:
{%- if collection.products.size == 1 -%}
{%- for product in collection.products -%}
<script>
window.location.href = '{{ product.url | within: collection }}';
</script>
{%- endfor -%}
{%- elsif section.settings.collection_products_grid == 'collage' -%}
Probably isn't the nicest way to do it but works like a charm.
User | Count |
---|---|
783 | |
142 | |
93 | |
63 | |
59 |