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?

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
New Member
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.

0 Likes
antoinelescun
Tourist
4 0 1

Did you succeed? I have the same issue currently.

0 Likes
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.

0 Likes
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
Excursionist
12 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.

0 Likes
DionSmith
Excursionist
12 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
Excursionist
12 0 4

What data do you get for product?

0 Likes