Skip collection page & display product page directly if only one product in that collection

Highlighted
New Member
1 0 0

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

0 Likes
Highlighted
Shopify Expert
10007 116 1820

Hey Mike,

The forum members will need more info here before help can be offered. Consider posting things like:

  • A link to your store / A link to the page that relates to your post
  • Name of the theme in use
  • Screen captures that help identify the section you're talking about

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. 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
New Member
9 0 0

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

  • My store can be viewed at veganlifeclothing.com
  • I am using the theme: Brooklyn
  • Below is a screenshot of the 3 featured collections

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)

 

 

0 Likes
Highlighted
New Member
1 0 0

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.

0 Likes