I am looking to make the default for all collections to be listed by Price: High to Low. The default now is set to Best Selling. I am looking to change the default code.
a little background: I have my site set up with a page that lists all my vendors. when the vendor name is clicked it goes to a page www.mysite.com/collections/vendors?q=VendorName
I want those pages to be listed by price High to Low.
Thank you for any help!
Just add this bit:
&sort_by=price-ascending
So the final link would be:
www.mysite.com/collections/vendors?q=VendorName&sort_by=price-ascending
thank you. the current code is:
{% for product_vendor in shop.vendors %}
{% assign its_a_match = false %}
{% capture my_collection_handle %} {{ product_vendor | handleize | strip | escape }} {% endcapture %}
{% assign my_collection_handle_stripped = my_collection_handle | strip | escape %}
{% for collection in collections %}
{% if my_collection_handle_stripped == collection.handle %}
{% assign its_a_match = true %}
{% endif %}
{% endfor %}
{% if its_a_match %}
- {{ product_vendor }}
{% else %}
- {{ product_vendor | link_to_vendor }}
{% endif %}
{% endfor %}
where would I enter your extension?
I appreciate your help!
This bit:
{% if its_a_match %}
- {{ product_vendor }}
{% else %}
- {{ product_vendor | link_to_vendor }}
{% endif %}
Change to either this:
{% if its_a_match %}
- {{ product_vendor }}
{% else %}
- {{ product_vendor | link_to_vendor }}
{% endif %}
Or this:
{% if its_a_match %}
- {{ product_vendor }}
{% else %}
- {{ product_vendor | link_to_vendor }}
{% endif %}
Cant see what your product_vendor stores, meaning if its a ?q=VendorName or just a VendorName, so one of those variants will work.
I see what’s happening. this would work: &sort_by=price-descending but you have it adding to the actual collections not the vendors in which I do not have collections. for the vendors I have created collections for I can simply change it in the admin. since I have hundreds of vendors I have not created collection and in that case it it creating the page www.mysite.com/collections/vendors?q=VendorName
I was able to get it to work. For reference the code is:
{% if its_a_match %}
{{ product_vendor }}
{% else %}
{{ product_vendor }}
{% endif %}
{% endfor %}
Thank you for pointing me in the right direction!
1 Like
Here is the way you can try to use. I did that for best selling but you can change the code according to your requirement.
Use below code: