Available inventory
Showcase your different locations’ available inventory directly in your theme to let customers see if stock is nearby for faster shipping, making their purchase decision easy.
This metafield is kept live updated with an array of references to your locations, complete with address information and their available inventory. As stock levels change via orders, inventory updates, or transfers, the metafield will be updated accordingly.
Details
- Name
espresso.available_inventory
- Description
Metafield namespace and key
- Name
list.metaobject_reference
- Description
Metafield type
- Name
variant
- Description
Scope of Shopify object that owns the metafield
Example content
[{
"location": {
"name": "Paris Warehouse",
"is_active": true,
"address": {
"address1": "123 Main Street",
"address2": "Apt. 1",
"city": "Paris",
"country": "France",
"country_code": "FR",
"formatted": "123 Main Street, Apt. 1, Paris, France, 75001",
"latitude": 48.856614,
"longitude": 2.3522229,
"phone": "(555) 555-5555",
"province": "Paris",
"province_code": "FR",
"zip": "75001",
},
},
"inventory_quantity": 123
},
{
"location": {
"name": "New York Warehouse",
"is_active": true,
"address": {
"address1": "123 Estate Street",
"address2": "Upper Floor",
"city": "New York",
"country": "United States",
"country_code": "US",
"formatted": "123 Estate Street, Upper Floor, New York, United States, NY, 10001",
"latitude": 40.7127837,
"longitude": -74.0059413,
"phone": "(555) 555-5555",
"province": "New York",
"province_code": "NY",
"zip": "10001",
},
},
"inventory_quantity": 44
}]
When you initially enable this metafield, the individual variant metafields will be set in a background task. If you have a large catalog, this may take anywhere from a few minutes to a few hours. Once the metafields are set, they will be updated in real-time
Example implementation
{% assign available_inventory = product.selected_or_first_available_variant.metafields.espresso.available_inventory.values %}
{% for available in available_inventory %}
{% if available.location.is_active %}
<div>
<h3>{{ available.location.name }}</h3>
<p>{{ available.location.address.formatted }}</p>
<p>Available inventory: {{ available.inventory_quantity }}</p>
</div>
{% endif %}
{% endfor %}