Hello everyone,
I’m currently working on a Shopify store and have encountered a challenge with product variants. In my product’s variants list, both deleted variants and out-of-stock variants are being marked as soldout or using the same class in the front-end. This makes it impossible to distinguish between the two in the Liquid templates or via CSS classes.
What I’m trying to achieve:
- Display only the in-stock and out-of-stock variants on the product page.
- Hide the deleted variants completely from the front-end so that customers do not see options that are no longer available.
- Keep out-of-stock variants visible but marked as “Sold Out” or similar, so customers are aware that these options exist but are currently unavailable.
The issue:
- Both deleted and out-of-stock variants appear to have the same properties in the Liquid code.
- They are both included in product.variants and have similar attributes, making it difficult to filter out deleted variants.
- I have tried various methods to distinguish between them, such as checking inventory_quantity, variant.available, and comparing variant IDs, but haven’t found a reliable solution.
Questions:
- Is there a way in Shopify’s Liquid templates to differentiate between deleted variants and out-of-stock variants?
- Does Shopify’s backend provide any property or flag that indicates a variant has been deleted versus just being out of stock?
- Has anyone faced a similar issue and found a workaround to hide deleted variants while showing out-of-stock variants?
What I’ve tried so far:
- Checking inventory_quantity: Deleted variants sometimes have inventory_quantity as nil, but this isn’t consistent.
- Comparing variant IDs: Attempted to compare variant IDs against a list, but deleted variants still appear in product.variants.
- Using variant.available: Both deleted and out-of-stock variants can have variant.available set to false.
Any insights or suggestions would be greatly appreciated!
Thank you in advance for your help.