How to display next incoming date on product page?

Hello everyone,

we will try to show out customers, if a product variant is incoming (after sold out), but it doesnt work - only “sold out”.


        		{% if current_variant.inventory_quantity == 0 %}
      				
                    	{% if product.selected_variant.incoming %}	
                      		Product incoming
                    	{% else %}  
                			Sold out
                		{% endif %}
                	
      			{% elsif current_variant.inventory_quantity > 5 %}
      				in stock
      			{% elsif current_variant.inventory_quantity < 5 %}
      				Only {{ current_variant.inventory_quantity }} in stock.
    			{% endif %}
              

Any ideas? :disappointed_face:

Thanks a lot,

Mike

Hello Mike,

without seeing how current_variant is assigned and changed on your page, I can’t tell for sure. But my guess would be that it differs from product.selected_variant leading to problems in the check.

Have you tried using current_variant instead?


        		{% if current_variant.inventory_quantity == 0 %}
      				
                    	{% if current_variant.incoming %}	
                      		Product incoming
                    	{% else %}  
                			Sold out
                		{% endif %}
                	
      			{% elsif current_variant.inventory_quantity > 5 %}
      				in stock
      			{% elsif current_variant.inventory_quantity < 5 %}
      				Only {{ current_variant.inventory_quantity }} in stock.
    			{% endif %}
 

The change is on line 4:

{% if current_variant.incoming %}

Hope this helps!

1 Like

Many thanks, it works! :slightly_smiling_face: :+1:

Is there a way to show the number incoming instead of just “product incoming”?

As far as I know, there is, unfortunately, no easy way to do this. The variant object doesn’t have such a field on the variant object and neither does the Storefront API provide it. It would be possible to create this functionality via an app, but I don’t know if there’s already an app that provides this functionality.