JQuery inventory management code working on live site but not test site

11 1 1

I have this code to update stock levels. It's working on my live site but the same theme on my test site isn't working - I just get output 'Currently in production, please contact me about pre-ordering '. Does variant.inventory_management not work on test sites?


      if (variant) {
      if (variant.inventory_management == "shopify" && variant.inventory_policy != "continue") {
        if (variant.inventory_quantity > 5) {
           jQuery('#variant-inventory').text("In Stock");
        else if( variant.inventory_quantity > 0){
          jQuery('#variant-inventory').text('In Stock - ' + variant.inventory_quantity + ' left');
        else {
          jQuery('#variant-inventory').text('Currently in production, please contact me about pre-ordering');
      } else {
        jQuery('#variant-inventory').text("This product is available");
    } else {
Shopify Expert
2686 67 694

Is your live store is older than Dec 2017? This may be affecting your test store:

As of Dec 5th 2017, inventory_quantity and inventory_policy fields accessed through a json Liquid filter are deprecated. The json filter will not output those fields for shops created after Dec 5th.


For newer shops you'd need a workaround like one I suggested in that thread

Want to hire me to tweak a theme? Mail me at tairli@yahoo.com!
My post solved your problem? Like it!
I am away till Feb-15.