Hide "out-of-stock" product options

This article describes how to hide product options from the options selector (usually dropdown list) if they are out of stock.
You will need to modify the code of ~\App_Code\CMSModules\Ecommerce\ProductOptionSelector.cs file. The change is quite simple:

In the mentioned file, please find method private void LoadSKUOptions().

Here, at line #495 (version 4.0), please add a clause "SKUAvailableItems > 0" to the where condition passed to the GetOptionCategorySKUs() method like shown below:

// Bind data
DataSet ds = SKUInfoProvider.GetOptionCategorySKUs(this.OptionCategoryId, "SKUEnabled = 1 AND SKUAvailableItems > 0");

Later you only need to ensure that initially all product options in stock have "inventory" available items set properly – greater than zero.
It is recommended to  use "Sell only if items are available" setting to ensure that the items count won't go into negative numbers when more users select the last option item concurrently.

See also: Number of available items

Applies to: Kentico CMS 4.0
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.