Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
So I have a product will 10 variants but I have also had to create separate listings for each variant (clients request) so that on a collection page you can view all variations. However, is there a way to redirect the variation product listing to the main product listing which contains the variants?
I have created a global url metafield called Redirecturl but can't figure out how to implement it. I tried adding the following code to the theme.liquid file but it didn't work:
{%- if product[handle].metafields.global.Redirecturl -%}
<script>
window.location = "{{ product[handle].metafields.global.Redirecturl }}";
</script>
{%- endif -%}
I am using the theme - Dawn.
Solved! Go to the solution
This is an accepted solution.
you don't need to add handle
product already contains hadnle
{%- if product.metafields.global.Redirecturl -%}
<script>
window.location = "{{ product.metafields.global.Redirecturl }}";
</script>
{%- endif -%}
That would be great if you could. Thanks
I would prefer to discuss it here so others can benefit from the solution. Thanks
This is an accepted solution.
you don't need to add handle
product already contains hadnle
{%- if product.metafields.global.Redirecturl -%}
<script>
window.location = "{{ product.metafields.global.Redirecturl }}";
</script>
{%- endif -%}
This was spot on thank you! I just needed to tweak the .global to .custom too.
Thank you so much!
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025