Display only to admins

uchizenmarux
Tourist
7 1 0

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

0 Likes
JHKCreate
Shopify Partner
2046 331 445

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

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkcreate.com
gina-gregory
Shopify Expert
663 37 142

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 %}

 

uchizenmarux
Tourist
7 1 0

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>

 

 

0 Likes
gina-gregory
Shopify Expert
663 37 142

There's no way to send an email without a 3rd party service.

0 Likes