I wonder if there any way or method for not showing the products that i have in my Shopify store which i have set the market for some countries and it should not show the product to the users from other countries for example i have product that should only be available in UK and USA but when i use Algolia in my Shopify web store and search for that product and lets say i am in Netherlands its showing the product and when i click to it to view the product details it shows 404 page not found.
If there is any way please let me know, i am using instant commerce for my theme for Shopify and i cant even access the code i just can add JS snippet.
enter image description here
the fix i tried is using plain JS to get the title for page not found and change it to Product not available, it changes the text but for example if user went to a page that is not in website it will give same message “Product unavailable in your country”.
function updatePageNotFoundText(e) {
// Select the title element
const titleElement = document.querySelector('.title.');
// Select the paragraph elements with both classes
const paragraph404Element = document.querySelector('.paragraph.hi8r512');
const paragraphBelowElement = document.querySelector('.paragraph.hi8r514.');
// Remove the elements if they exist
if (paragraph404Element) {
paragraph404Element.remove();
}
if (paragraphBelowElement) {
paragraphBelowElement.remove();
}
if (titleElement) {
titleElement.textContent = "Product unavailable in your country";
titleElement.style.fontSize = '24px';
}
}
document.addEventListener('instantLoadPage', updatePageNotFoundText);
Anlel Napleon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.