Liquid, JavaScript, themes, sales channels
Is there a way to show some div if it detects that the user is the admin? Because we are b2b style , we do not sell and only redirect the customer to a third-party eCommerce site that sells it. I have a button that detects if they have stock or not, if they do not have any the button will not show. The problem is that buttons are only shown depending on what country you are in. So different countries have different links and sources.
I want that if detects that it does not have stock, a sticky top bar will show that it does not have stock and only admins can see it. Or s it possible also to just email us if it goes out of stock.
Thanks
Hi There,
Can you please provide us with more details to how you want it done?
We can assign specific scenarios based on admin emails for detection, that should do it
Awaiting your reply
There are a couple different options I can think of.
1. If the admin opens the site using the 'eye' button next to Online Store in the admin, they get the admin preview bar at the bottom of the site. You could check for the existence of that, and then show your stock bar. You could even do this with liquid like this, I think.
{% if content_for_header contains 'AdminBarInjector' %}
... show your stock bar
{% endif %}
2. Have your admin create customer accounts and tag them as 'admin', then you can do a conditional statement like this:
{% if customer.tags contains 'admin' %}
... show your stock bar
{% endif %}
Thank you for your replies. Any admin or staff of the website can see that sticky top bar. To see it more clearly this is the code that triggers the button, so if the result of the available quantity is false the topbar sticky will show. So that we are aware if it is already out of stock visually or is possible to send email to notify us from there without using third party service?.
$(document).ready(function() {
var arID = "MLA903951112";
$.get("http://ipinfo.io", function(response) {
var userCountry = response.country;
switch (userCountry) {
case "AR":
$.ajax({
url: "https://api.mercadolibre.com/items/" + arID,
type: "get",
data: {
type: 0
},
success: function(data) {
if (data["available_quantity"] > 0) {
//Display Button
$(".show-btn").css('display', 'block');
// Shop Top Bar for admin or staff
$("sticky-top").css('display', 'block');
}
}
});
break;
}
}, "jsonp");
});
</script>
There's no way to send an email without a 3rd party service.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024