Shopify Liquid store_availability is empty

bobby10
Tourist
5 0 3

Hi,

i have 2 locations where ive enabled pickup.

My Test product has 1 variant with an inventory of 5 at location 'A' and 2 at location 'B'.

In Liquid i now have implemented following code to my product-template:

{% if product.selected_or_first_available_variant.requires_shipping %}
  {% for variantPickupLocation in product.selected_or_first_available_variant.store_availabilities %}
    {{ variantPickupLocation.available }}
  {% endfor %}
{% endif %}

 

I would expect to see true/false on my product page, but the store_availabilties object is empty.

With the URL https://mystore.myshopify.com/variants/36996986241178/?section_id=store-availability i can see however, that my store/product settings are correct and it returns store availabilities.

What am i doing wrong?

Replies 25 (25)

bobby10
Tourist
5 0 3

Ok, its a bit crazy.

First time loading the product page it loads the data. But after refreshing the page with F5 the same liquid code returns nothing.

Also variant.store_availabilities should return a list of StoreAvailability Objects back instead it returns just the first StoreAvailability Object back, although my test product is available at 2 stores.

How is this possible, there has to be an error in the backend.

 

Could you guys please check this problem?

pomeo
Visitor
1 0 0

First time loading the product page it loads the data. But after refreshing the page with F5 the same liquid code returns nothing.

When I put this {{product.selected_or_first_available_variant.store_availabilities.first.location.address.city}} and try open page, then with "/product-handler?variant=some_variant_id" I see "city", but when I open without ?variant "/product-handler" I see nothing. I try different ways, but store_availabilities empty without ?variant in url.

antoinelescun
Tourist
4 0 1

Did you succeed? I have the same issue currently.

bobby10
Tourist
5 0 3

No, it has to be a bug in the backend. Ive contacted the Shopify Support but got no answer til now. I hope they fix it soon and let everyone know in the community forums.

theheartypixel
Tourist
7 0 2

Also having this same issue, so I was wondering if you had figured out a resolution or if Shopify got back to you?

DionSmith
Shopify Partner
14 0 4

I am having the same issue. I would like to display how many are in stock at each location but it is returning nothing.

DionSmith
Shopify Partner
14 0 4

I just chatted with Shopify Support and they were trying to say that it is a theme issue and I should talk to a Shopify Expert. I told them that it is a liquid issue and they should check to see why it returns no info. Obviously the store info is stored somewhere since I have two locations so there must be some way to use the info. I even tried their tutorial https://shopify.dev/tutorials/add-store-availability and it didn't work. Interesting that they give you the tutorial but no working sample of it working. They are going to check into it. Hopefully I will hear back soon and keep you updated.

theheartypixel
Tourist
7 0 2

Agreed that it seems to be a Liquid issue. Displaying a variant object as JSON shows there is literally no data about store availability, so variant.store_availabilities from the Shopify documentation doesn't work. For instance, here is all of the data I am getting for a variant:

{
   "id":37268036845729,
   "title":"Small",
   "option1":"Small",
   "option2":null,
   "option3":null,
   "sku":"2026",
   "requires_shipping":true,
   "taxable":false,
   "featured_image":null,
   "available":true,
   "name":"Mint Chocolate \u0026 Almonds Holiday Gift Box - Small",
   "public_title":"Small",
   "options":[
      "Small"
   ],
   "price":4795,
   "weight":2268,
   "compare_at_price":null,
   "inventory_management":"shopify",
   "barcode":"",
   "requires_selling_plan":false,
   "selling_plan_allocations":[
      
   ]
}

 

Thanks for the update! Definitely interested to see what else you find out.

DionSmith
Shopify Partner
14 0 4

What data do you get for product?

theheartypixel
Tourist
7 0 2

Product JSON data also yields nothing as far as store availability:

 

{
   "id":2093386236000,
   "title":"Mint Chocolate \u0026 Almonds Holiday Gift Box",
   "handle":"mint-chocolate-almonds-holiday-gift-box",
   "description":"\u003cp\u003eThis delightful gift has a combination of sweet and salty treats and will be a hit with anyone on your list! \u003c\/p\u003e\n\u003cp\u003eHand-packed in a tasteful green gift box, each gift includes the following: \u003c\/p\u003e\n\u003cul\u003e\n\u003cli\u003eone pound bag of Milk Chocolate covered almonds\u003c\/li\u003e\n\u003cli\u003eone pound bag of Mint Chocolate covered almonds\u003c\/li\u003e\n\u003cli\u003eone 6 oz can of Wasabi \u0026amp; Soy Sauce almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Roasted Salted almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Honey Roasted Chipotle almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Salted Caramel almonds\u003c\/li\u003e\n\u003cli\u003ethree 1 oz foil packets of Smokehouse almonds\u003c\/li\u003e\n\u003c\/ul\u003e",
   "published_at":"2019-04-18T14:45:14-07:00",
   "created_at":"2019-04-18T14:45:16-07:00",
   "vendor":"BDG",
   "type":"Sweets and Specialty Items",
   "tags":[
      "gift",
      "gift box",
      "gift pack",
      "type:Jordan Almonds",
      "type:Lemon"
   ],
   "price":4795,
   "price_min":4795,
   "price_max":4795,
   "available":true,
   "price_varies":false,
   "compare_at_price":null,
   "compare_at_price_min":0,
   "compare_at_price_max":0,
   "compare_at_price_varies":false,
   "variants":[
      {
         "id":37268036845729,
         "title":"Small",
         "option1":"Small",
         "option2":null,
         "option3":null,
         "sku":"2026",
         "requires_shipping":true,
         "taxable":false,
         "featured_image":null,
         "available":true,
         "name":"Mint Chocolate \u0026 Almonds Holiday Gift Box - Small",
         "public_title":"Small",
         "options":[
            "Small"
         ],
         "price":4795,
         "weight":2268,
         "compare_at_price":null,
         "inventory_management":"shopify",
         "barcode":"",
         "requires_selling_plan":false,
         "selling_plan_allocations":[
            
         ]
      }
   ],
   "images":[
      "\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_inner.jpg?v=1555623916",
      "\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_outer.jpg?v=1555623916"
   ],
   "featured_image":"\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_inner.jpg?v=1555623916",
   "options":[
      "Size"
   ],
   "media":[
      {
         "alt":null,
         "id":1667585998944,
         "position":1,
         "preview_image":{
            "aspect_ratio":1.0,
            "height":851,
            "width":851,
            "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_inner.jpg?v=1569218684"
         },
         "aspect_ratio":1.0,
         "height":851,
         "media_type":"image",
         "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_inner.jpg?v=1569218684",
         "width":851
      },
      {
         "alt":null,
         "id":1667586031712,
         "position":2,
         "preview_image":{
            "aspect_ratio":1.0,
            "height":664,
            "width":664,
            "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_outer.jpg?v=1569218684"
         },
         "aspect_ratio":1.0,
         "height":664,
         "media_type":"image",
         "src":"https:\/\/cdn.shopify.com\/s\/files\/1\/0094\/5730\/3648\/products\/mint_box_outer.jpg?v=1569218684",
         "width":664
      }
   ],
   "requires_selling_plan":false,
   "selling_plan_groups":[
      
   ],
   "content":"\u003cp\u003eThis delightful gift has a combination of sweet and salty treats and will be a hit with anyone on your list! \u003c\/p\u003e\n\u003cp\u003eHand-packed in a tasteful green gift box, each gift includes the following: \u003c\/p\u003e\n\u003cul\u003e\n\u003cli\u003eone pound bag of Milk Chocolate covered almonds\u003c\/li\u003e\n\u003cli\u003eone pound bag of Mint Chocolate covered almonds\u003c\/li\u003e\n\u003cli\u003eone 6 oz can of Wasabi \u0026amp; Soy Sauce almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Roasted Salted almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Honey Roasted Chipotle almonds\u003c\/li\u003e\n\u003cli\u003e\n\u003cspan\u003eone \u003c\/span\u003e6 oz can of Salted Caramel almonds\u003c\/li\u003e\n\u003cli\u003ethree 1 oz foil packets of Smokehouse almonds\u003c\/li\u003e\n\u003c\/ul\u003e"
}

 

bjoernwolf
Shopify Expert
4 0 0

I have problems here too. It worked to the last days and I got at least the correct information back. But after I changed some location configuration (I added/enabled one) I only get one stalled information about availability at one location that is already zero and there is no inventory available anymore. On the other hand the other two locations which have inventory are not even showing up.

DionSmith
Shopify Partner
14 0 4

I really don't understand Shopify sometimes. This is clearly a liquid object issue and they keep trying to tell me it has to do with a theme and that I should get some help from the Shopify Experts. I don't need a shopify expert to tell me what I already know.

Here is Shopify's response.

 

I was just double checking with our team if this was anything that could be looked at. From my end there is nothing that I can further do for you on this, I recommend reaching out to a Shopify Experts to see if there is anything that they can take a look at or see if anything can be changed to get this working properly for you!

bjoernwolf
Shopify Expert
4 0 0

I think the main problem here is, that it is obviously not a publicly documenter "Ajax API" (yet), besides the blog post and some bits and pieces here and there it is not clearly documented. For our customer the reference/test implementation just stopped working last week, before that everything was fine. Now the returned response is not empty or anything, its just wrong, not up-to-date and reflecting the current inventory situation.

Now the customer cannot test this in detail and we have to postpone it.

The only other solution would be to implement it on the Warehouse and let it populate some metafields, which just does not make sense if we (theoretically) already have this information available.

teifidigital
Tourist
4 0 1

Hello everyone!

This has been bothering me for weeks! But I figured out how to fix the issue. Essentially, I think shopify changed some rules where the availability object required in-store pick up to actually be enabled for those locations it wont work properly. 

I had imported my entire catalogue and had items stocked in only certain locations with picked up enabled. Then I disabled pick up and added new products and stocked new products in new location but this was not showing on the front end of the site. After I re enabled pick up for all products and waited a few days the availability object had been populated for all 100K of my client's products.

DionSmith
Shopify Partner
14 0 4

Does anyone have an example of this working on how to use it in the product or product template page?

expandagency
Visitor
1 0 0

Also coming up blank on this.

Tested this in a sandbox site

Theme: Debut
File: product-template.liquid
Issue: variant.store_availabilities ( Nothing is returned - EMPTY - 4 locations setup all with stock)

<h1>TESTING</h1>	
<hr>
product.variant.available: {{ product.variant.available }}
<br>
{% for variant in product.variants %}
    <!-- Returns TRUE -->
    variant.available: {{ variant.available }}
    <br>
    <!-- Returns with Qty -->
		variant.inventory_quantity: {{ variant.inventory_quantity }}
		<br>
    <!-- RETURNS EMPTY, NO DATA -->
    variant.store_availabilities: {{ variant.store_availabilities }}
		<br>
{% endfor %}

 

potabox
Tourist
3 0 0

@expandagency Did you enable Pick Up for any location yet?

If not, try it: Go to Settings -> Shipping and Delivery -> In the Local pickup section, select Manage one in the list -> Check to This location offers local delivery

And remember, make sure the variant param in the URL must be present, eg. ?variant=34999421862043

DionSmith
Shopify Partner
14 0 4

I have tried that and still get no info returning. The info for adding the store info to the page is here but when I use variant.store_availablity.location or available no data is returned.

https://rock-shop-test-account.myshopify.com/collections/men/products/campus-crew-vintage-blue-t-shi...

            <h1>TESTING</h1>
<hr>
product.variant.available: {{ product.variant.available }}
<br>
{% for variant in product.variants %}
    <!-- Returns TRUE -->
    variant.available: {{ variant.available }}
    <br>
    <!-- Returns with Qty -->
variant.inventory_quantity: {{ variant.inventory_quantity }}
<br>
    <!-- RETURNS EMPTY, NO DATA -->
    variant.store_availabilities: {{variant.store_availability.available }}<br>
{{variant.store_availability.location              }}<BR>
                  {{variant.store_availability.available              }}
<br>
{% endfor %}
concordadams
Shopify Partner
5 0 17

Re: this discussion. We really need this data added to the variant object level. ALSO, (i haven't been able to find it) with the addition of local delivery to the native Shopify platform, it would be nice to have a shop.local_delivery.zip_codes object to just output what we've put in the dashboard so it can be tested against the shopper's zip

Al4j0
Shopify Partner
6 0 1

Hello I hope it helps someone :
(using Jquery)

 $(document).ready( function(){ 
            $.ajax({url: "/variants/{{ product.selected_or_first_available_variant.id }}/?section_id=pick-availability", success: function(result){
             $('#available').html("");
              $('#available').html(result);
       }});

 Create a section called "pick-availability" :

{%- assign pick_up_availabilities = product_variant.store_availabilities | where: 'pick_up_enabled', true -%}
{%- if pick_up_availabilities.size > 0 -%}
<ul>
{%- for availability in pick_up_availabilities -%}
<li>
<h3>{{ availability.location.name | escape }}</h3>
<p>
{%- if availability.available -%}
 Available, {{ availability.pick_up_time | downcase }}
{%- endif -%}
</p>
{%- assign address = availability.location.address -%}
<address>
{{ address | format_address }}
{%- if address.phone.size > 0 -%}
<p>{{ address.phone }}</p>
{%- endif -%}
</address>
</li>
{%- endfor -%}
</ul>
{%- endif -%}

  

Confirm your addresses are verified.
Go to Admin > Settings > Locations.

Edit the location that's not coming up in your store_availabilities data.
Make sure you're not getting the following message when you edit an address.

 

Al4j0_0-1669324920000.png

 


Use the address autocomplete field so Shopify can help you add your address in the correct format, Save your location.

 your variant must have your locations enabled 

Finally in your shipping configuration you must have "offers pickup" activated in all your locations

Maxineholder
Visitor
1 0 0

which file do you put the top (jquery) code pls?

thk116
Excursionist
36 0 7

Had the same issue with variant location inventory only reflecting the first location in liquid data when we have 3 locations. Our first location is enabled for store pickup but our other locations are not. Somehow, enabling store pickup for the other location impacted the liquid data so it now reflects correctly, almost like it forced a fresh cycle through the data. You can go ahead and disable store pickup after that if you need to like we did and it will still reflect correctly. 

For reference, our store is Shopify 1.0. I'm curious if anybody is on a 2.0 store and experiencing the same issue?

Sebastian_Young
Shopify Partner
116 6 37

Thanks for the tip but unfortunately not possible for us as we do not use multi-origin shipping.

HoangNguyen
Shopify Partner
1 0 1

I had this error and I fixed it with the following: Settings > Shipping and delivery > Local pickup > uncheck all locations offering local pickup > then re-enable locations that provide local pickup.

thk116
Excursionist
36 0 7

This has worked for us too in the past, but has also reverted back to having the issue as well. Hacky and not totally reliable but seems to address the issue at least temporarily.