What's your biggest current challenge? Have your say in Community Polls along the right column.

Display Variant quantity

Solved

Display Variant quantity

Zeuligan
Shopify Partner
12 1 1

How do I display each variants quantity inside the product-variant-option.liquid?

Tried pretty much any combo I could think of, but not getting any values...
Need the quantity of each listed variant (for size) so I can display it next to each size


Accepted Solution (1)
namphan
Shopify Partner
2067 273 306

This is an accepted solution.

Hi @Zeuligan,

You can use the following for the product-variant-options.liquid file:

Screenshot.png

Code:

{{ value.variant.inventory_quantity }}
Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

View solution in original post

Replies 9 (9)

namphan
Shopify Partner
2067 273 306

Hi @Zeuligan,

Please send the website link, I will check it for you

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

Mehran_Ali
Shopify Partner
447 57 69

Hi @Zeuligan 

 

Can you share you store URL and Password if it password protected so I can check and try to help you out

-If this solution helps you, kindly LIKE THIS REPLY and MARK AS A SOLUTION OR

Buying Me A Coffee.

-If you need an expert Shopify developer for customization and development, feel free to contact me.


Email: Mehran.ali5300@gmail.com


WhatsApp: +92 343 0211536

DaisyVo
Shopify Partner
1070 134 150

@Zeuligan 

 

Please share with me your store URL and show me specifically which place do you want to add the feature

 

Best,

 

Daisy

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution

Zeuligan
Shopify Partner
12 1 1

I can't share anything, its both a secret project and mostly it's a local CLI environment. It's Dawn 15 and it's in the product-variant-option.liquid. Basically next to each size I want to display that variants stock levels. 

Zeuligan
Shopify Partner
12 1 1

I'm closer, but not solved. 

 

{% assign matching_variant = product.variants | where: 'option2', value | first %}
That gives me access to variant stock with for example 
matching_variant.inventory_quantity

Problem is that this is for the first variant only (if I got 2 colors the inventory quantity is only for the first color/variant, even if I choose 2nd color/variant). 
Anyone got any smart input?

Not sure if this makes it clear but the block "Inventory Status" is what I'm trying to implement PER variant, not one value displayed for the selected variant, but for all LISTED variants that are size (option 2). So I can display available stock in a list next to corresponding size value. 
namphan
Shopify Partner
2067 273 306

This is an accepted solution.

Hi @Zeuligan,

You can use the following for the product-variant-options.liquid file:

Screenshot.png

Code:

{{ value.variant.inventory_quantity }}
Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com
Zeuligan
Shopify Partner
12 1 1

THANK YOU SIR 😍 I'm so grateful. Works like a charm 🙂 

Zeuligan
Shopify Partner
12 1 1

You again, thats 2 times you helped me. Thank you!
Do you know if there is a way to show only the available variant options when the 

{%- for value in option.values -%} loop?

For my test product I got 2 colors and 6 sizes for color 1 and 7 sizes for color 2 (I deliberately deleted one size, rather than stock 0)
Now matter how I do, both variants list 7 sizes, with the only difference that for color 1, the 7th size is listed as out of stock. 
Can you delist the actual variant size if it's not avaiable? Ofc I could just set that variant size to 0, but was curious if it's possible without rewriting the entire loop. 
namphan
Shopify Partner
2067 273 306

Hi @Zeuligan,

Please send me the product link describing this, I will check it out

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com