Locations

Sets a product level metafield to reference the locations where its variants may be stocked. Use it as a filter condition in your admin or in your smart collections to view products being stocked at specific locations.

This metafield is kept live updated with an array of references to your locations where some (or all) of the product's variants may be stocked. As these locations change, the metafield will be updated accordingly.

Details

  • Name
    espresso.locations
    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

[{
    "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",
    },
},
{
    "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",
    },
}]

When you initially enable this metafield, the individual product 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 locations = product.metafields.espresso.locations.values %}

{% if locations %}
    <h2>Locations</h2>
    {% for location in locations %}
    {% if location.is_active %}
        <div>
            <h3>{{ location.name }}</h3>
            <p>{{ location.address.formatted }}</p>
        </div>
    {% endif %}
    {% endfor %}
{% endif %}

See also

Was this page helpful?