creative designer

There can be times that you want to land on a specific variant on your product page, and have it selected – ready to be added to cart.

With the power of JavaScript you’re able to do just that. Take a peek at the eCommerce forums post that runs through the thinking, with development of the idea. Later posts also give alternate uses so be sure to give it the full read.

var initSelect = function(){if(window.location.hash) {var s = $('#select-variant');var h = window.location.hash.substring(1);s.find('option').each(function() {var t = $(this);if(t.attr('data-sku') == h){$('#select-variant-option-0').val(t.text()).trigger('change');}});}}

[2014 update] Good news is that this concept has now been included into the default Shopify Scripts. You might not need this anymore. I'd like to think that the work that myself and others did on that thread linked above gave Shopify a bit of inspiration.

Like to work with me?

Let's talk