Skip to content

Instantly share code, notes, and snippets.

@osama2kabdullah
Created February 5, 2024 05:35
Show Gist options
  • Save osama2kabdullah/47ba37b22046d84c4422f86350b23fa2 to your computer and use it in GitHub Desktop.
Save osama2kabdullah/47ba37b22046d84c4422f86350b23fa2 to your computer and use it in GitHub Desktop.
Shopify Collection Filter AJAX request URL.
Shopify.queryParams = {};
if (location.search.length) {
var params = location.search.substr(1).split("&");
$.each(params, function (i, param) {
var keyValue = param.split("=");
if (keyValue.length) {
Shopify.queryParams[decodeURIComponent(keyValue[0])] =
decodeURIComponent(keyValue[1]);
}
});
}
Shopify.queryParams.sort_by = "best-selling"; // you can change it by dynamically
const view_all_URL = location.origin + location.pathname + "?" + $.param(Shopify.queryParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment