Filter by Tags - did something change?

Shopify Partner
22 0 1

I've implemented a filter by tag system on my collection pages, both on the 'live' store for my client, and on my development store. This had been working perfectly last week, but when I randomly check it today these filters take people to a 404 page.

It seems the filters aren't generating the right URL, in this case this is the result after choosing 'XL' from the dropdown: 

http://test-store.myshopify.com/collections/knitwearxl

It puts the filter tag right after the collection name, without a + or any special syntax.

I keep detailed backups of my themes, and have tried plenty of earlier versions where this functionality worked for certain, both on my dev store and my clients (currently not launched yet) store.

Is anybody noticing the same problem? This is really scary as it seemed to have broken on its own.. I hope someone here can shed some light on the matter.

 

Thanks for any help or advice!

 

 

 

0 Likes
Shopify Partner
22 0 1

To be more clear, it is not giving me a / when creating the 'filtered' URL.

0 Likes
Shopify Expert
685 0 68

Try adding the trailing slash below [after "/swim"]:

/* Product Tag Filters - Good for any number of filters on any type of collection pages */
/* Give you product tag filter select element a class of coll-filter */
/* Give your collection select a class of coll-picker */
/* Brought to you by Caroline Schnapp */
var allFilters = jQuery('.coll-filter, .coll-picker');
allFilters.change(function() {
  var newTags = [];
  jQuery('.coll-filter').each(function() {
    if (jQuery(this).val()) {
      newTags.push(jQuery(this).val());
    }
  });
  if (newTags.length) {
    var query = newTags.join('+');
    if (jQuery('.coll-picker').length) {
      window.location.href = '/collections/' + jQuery('.coll-picker').val() + '/' + query;
    }
    else {
      // IN THE LINE BELOW
      window.location.href = jQuery('<a title="Show products matching tag " href="/collections/swim/"></a>').attr('href') + query; 
    }
  }
  else {
    if (jQuery('.coll-picker').length) {
      window.location.href = '/collections/' + jQuery('.coll-picker').val();
    }
    else {
      window.location.href = '/collections/swim';
    }
  }
});

 

I'm a million different people
0 Likes
Shopify Partner
22 0 1

Thank you so much Ricky, you're amazing!

No idea why this suddenly changed for me. Thank you for looking into it!

0 Likes
Shopify Expert
685 0 68

You're welcome

I'm a million different people
0 Likes