• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Hide Product Variations on basis of Stock value

Engaged ,
Dec 11, 2016 Dec 11, 2016

Copy link to clipboard

Copied

With liquid we have better control over the system's output and use it to tweak system's behavior. One such scenario is if variations are enabled for a product how can we display/hide the variations that has inStock value 0. Via BC system setup, we can hide a product when its inStock value becomes 0, that means, when all the variations inStock value becomes 0. But using liquid we can hide the variation options that has inStock value 0.

Add the code on the attached link to the product large layout:

http://dhell.businesscatalyst.com/productinventoryupdate.png

Note: The code works but with two conditions:

1) There is ONLY ONE SET of the attributes, screenshot: http://prntscr.com/di898h

2) The attributes MUST be set to Radio List: http://prntscr.com/di89ru

In the Adobe code, we are first looping through the inventoryByAttributes array to fetch if a variations inStock value is 0, if yes, then we are using javascript to target that variation to hide it.

Hope this helps.

Regards,
Gaurav Aggarwal

Message was edited by: gaurav aggarwal

TOPICS
How to

Views

574

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2016 Dec 21, 2016

Copy link to clipboard

Copied

LATEST

Hiho

I´m also trying to hide product variation with inventory control enabled. Using {{inventoryByAttributes}} doesn´t do the trick. Buy button doesn´t work when you are using this object... this is only usable for display purposes and have no functionality. Am I wrong? I hope so

Why script and display: none?

You can ask for items that are enabled AND have a inStock value > 0.

Like so:

<ul>

{% for i in inventoryByAttributes -%}

{% if i.inStock > 0 and i.enabled == true -%}

<li>id: {{i.id}}, inStock: {{i.inStock}} do something more here... </li>

{% endif -%}

{% endfor -%}

</ul>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines