I’m developing a custom theme for a small, new business which is currently limiting the shipment of certain products to one country. To achieve this, we have set up a unique shipping rate for all the relevant products in that country (Switzerland). For all other products, we have set up a shipping rate for each market, making sure to exclude the relevant products.
This solution works fine, but I haven’t found a way to distinguish between out-of-stock products and unshipable products in the theme for non-Swiss visitors. Currently, all products that cannot be shipped to the visitor’s location are labelled as “Sold out”.
While both conditions result in the same outcome (the product cannot be purchased), I would like to provide non-Swiss visitors with more information than just the ‘Sold out’ label. Is there a way to distinguish between out-of-stock products and non-shippable products in Liquid?
Update: I found a workaround but I’m not sure whether this approach is robust enough. Based on the availableconditions for the product object, I check whether any of the other available conditions are being met when a product is unavailable, in order to determine whether the product can be shipped to the current market.
{% if product.available == false and product.selected_or_first_available_variant.inventory_quantity > 0 or product.selected_or_first_available_variant.inventory_policy == 'continue' or product.selected_or_first_available_variant.inventory_management == nil %}
→ Product cannot be shipped to location
{% elsif %}
→ Product is sold out
{% endif %}
I haven’t found any issues with this implementation in my testing yet, but I’d be grateful if someone could double-check whether I’m missing any edge cases.
We’ve run into this quite a bit with our bundles app as well. Bundles don’t have their own inventory and can’t be assigned to specific shipping profiles, so they always fall under the default profile. Some merchants don’t have any shipping rules set up in that default profile (for the default location), which causes bundles to show as Sold Out on collection pages (due to available == false).
That doesn’t actually prevent customers from buying the bundles, but it’s confusing and hard to explain to merchants.
It would be great if available reflected only the inventory conditions, and there were a separate property to indicate whether the product is covered by a valid shipping profile.