Forum
Additional parameter to URL for sorting
Hi,
I am using a URL parameter to filter categories in a perch_shop_products
so have this as my URL at the moment:
https://mywebsite.com/?category=electric
Which is fine. Now when viewing those products I want to have price sorting options. I have this little form on the page currently:
<form method="get">
<button name="price" value="asc">Sort price ascending</button>
<button name="price" value="desc">Sort price descending</button>
<button>Default sort</button>
</form>
But that is overriding the existing parameter, so I am sorting by price but for all the products rather than the selected category. Is there a way I can add the new parameter to the existing? I want to end up with:
https://mywebsite.com/?category=electric&price=asc
For example, though if there is no category filter it would need to still work to output
https://mywebsite.com/?price=asc
Help greatly appreciated!
Your form needs to include the category.
Great that has sorted it - cheers Drew, 2 for 2 so far today!