What's your biggest current challenge? Have your say in Community Polls along the right column.

Multi-Word Vendors Leading to 404 Collection Pages

Solved

Multi-Word Vendors Leading to 404 Collection Pages

MontanaGC
Visitor
2 0 1

Hi All! 

I appreciate the help anyone can provide! I'm looking to make the Vendor/Brand name from product pages clickable and lead to auto-populated collections by vendor. I'm using this code:

 

{% if product.vendor %}

  <div class="vendor-name">

    Brand: <a href="/collections/vendors?q={{ product.vendor | handleize }}">{{ product.vendor }}</a>

  </div>

{% endif %}

 

The problem is, for single-word vendors, it populates just fine, but if a vendor name is more than one word, it leads to a 404 page. I'm sure it's just a small thing I'm missing, but any ideas there? Thanks again! 

Accepted Solution (1)

PaulNewton
Shopify Partner
7450 657 1565

This is an accepted solution.

Hi @MontanaGC 👋 Confirm if it's a url encoding problem, try manually replacing the space, or dashes,  with the space url encoding: %20.

 

The vendor value is being put into a query parameter so it needs to be url encoded not handelize as that inserts dashes and the vendor name does not have spaces in it.

https://shopify.github.io/liquid/filters/url_encode/ , e.g. q={{ product.vendor | url_encode }} 

 

If you need this debugged further or theme customization then contact me for services
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Replies 2 (2)

PaulNewton
Shopify Partner
7450 657 1565

This is an accepted solution.

Hi @MontanaGC 👋 Confirm if it's a url encoding problem, try manually replacing the space, or dashes,  with the space url encoding: %20.

 

The vendor value is being put into a query parameter so it needs to be url encoded not handelize as that inserts dashes and the vendor name does not have spaces in it.

https://shopify.github.io/liquid/filters/url_encode/ , e.g. q={{ product.vendor | url_encode }} 

 

If you need this debugged further or theme customization then contact me for services
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


MontanaGC
Visitor
2 0 1

This worked like a charm! Thanks, Paul!