Emergency situation

In case of emergencies or breakdowns, you can send an SMS to our emergency hotline

On-call phone (SMS only)

+45 29 70 15 95

Send an SMS with the following information:

  • Your name and webshop
  • Description of the problem
  • Your callback phone number

Notes: This service is only for critical situations where your webshop is down or has serious problems. For regular support, please use our normal support channels.

Show variants not in stock

Guide to display out-of-stock variants in your Shoporama theme so customers can see the full range and sign up for stock alerts.

Reading time: approx. {eight} minutes
Shopejer Developer

For example, if you have a profile with six sizes, but only three are in stock, Shoporama will show only the three available by default. You can customize your theme to show all variants, including those that are out of stock, giving the customer a complete overview of the range.

Default behavior

By default, Shoporama only shows variants that are in stock. This prevents the customer from choosing a size or color that is not available. In most shops this works fine, but if you sell a collection where some sizes are often out of stock, it can be an advantage to show all variants and only mark those that are not currently available.

The right methods in the theme

On a SafeProduct object, you have two methods you can call in your Smarty template:

  • $product->getInStockVariants() returns only variants that are in stock.
  • $product->getStockVariants($only_in_stock, $hide_stock) returns all variants. Set the first parameter to false to include both out of stock and available variants.

Both methods return an array of rows (not variant objects). Each row is an associative array with the following keys:

  • attr_name, the attribute name (e.g. "Size")
  • attr_tag, the attribute's tag (code-friendly name, e.g. "size")
  • name, name of the variant value (e.g. "M" or "Red")
  • cnt, number in stock (0 if out of stock, null if you have chosen to hide stock count)
  • attribute_id and attribute_value_id, IDs you use when adding the variant to the cart
  • weight, the sort order
  • price and sale_price, variant-specific price if applicable

Show all variants in the theme

Change to getStockVariants(false) in your product template. Example as dropdown:

<select name="attribute[]"> <{foreach $product->getStockVariants(false) as $variant}> <option value="<{$variant.attribute_value_id}>" <{if $variant.cnt <= 0}>disabled<{/if}>> <{$variant.name}><{if $variant.cnt <= 0}> (out of stock)<{/if}> </option> <{/foreach}> </select>

Example as clickable buttons with visual marking of out of stock options:

<{foreach $product->getStockVariants(false) as $variant}> <button type="button" data-attribute-id="<{$variant.attribute_id}>" data-attribute-value-id="<{$variant.attribute_value_id}>>" class="variant-btn <{if $variant.cnt <= 0}>is-sold-out<{/if}>" <{if $variant.cnt <= 0}>disabled<{/if}>> <{$variant.name}> </button> <{/foreach}>

Styling of out of stock variants

  • Add the disabled attribute to out of stock options so they cannot be selected.
  • Visually mark them with a CSS class such as a muted color, strikethrough or a diagonal stripe.
  • Display the text (out of stock) after the variant name so it is clear to the customer.

Hide stock quantity

If you don't want to reveal exactly how many are in stock (e.g. "only 2 left"), you can set the second parameter to true:

<{foreach $product->getStockVariants(false, true) as $variant}> ... <{/foreach}>

Then $variant.cnt will be null on all variants that are in stock. You can still see if a variant is out of stock because it will have the value 0.

Combine with stock notification

For out-of-stock variants, you can offer the customer to receive an email when the item is back in stock. This way, the customer won't disappear even if the desired size or color is currently out of stock.

Tip: When the customer can see the entire range, the selection seems broader and increases the likelihood that the customer will return when the item is back in stock.

Frequently asked questions

Do I have to show all out of stock variants on all products?

Not necessarily. It makes the most sense on fashion products with clear size categories (S, M, L) or when a collection typically sells out in certain sizes first. On very large ranges, or on products where variants are often permanently discontinued, it can cause confusion.

Can the customer add a discontinued variant to the cart?

No, they can't. When the disabled attribute is set on the option, it cannot be selected. If you are building custom JavaScript, make sure to block out of stock variants yourself so that a "Add to cart" click does not go through.

Where can I find the current variant loop in my theme?

Search for getInStockVariants or getStockVariants in your theme folder (typically in product/view.html). That's where you need to make the change. Remember to save a copy of the file first.

Does it affect Google Shopping or other feeds?

No, it won't. The display of out of stock variants is only a change on the product page itself in your online shop. Product feeds are handled separately and are based on the actual stock count per variant.

What happens to the statistics when I show out of stock variants?

Conversion rates may increase slightly because more customers sign up via stock notification, but you also run the risk of customers dropping out because their desired size is sold out. Do a split test before rolling out the change to the entire shop.

How do I quickly see if a variant is in stock in admin?

Go to the product in admin and look under "Variants". Each variant has its own stock count and you can filter the product overview by stock status.

Can I show the total number of out of stock variants?

Yes, you can. Count rows where cnt is 0 in the loop. This can be used for a message like "3 out of 6 sizes are out of stock".

What is the difference between getInStockVariants and getStockVariants?

getInStockVariants() always returns only the variants that are in stock. getStockVariants() can give you both stock-only (with true as the first parameter) or all variants (with false). Use the latter when you want to show out of stock options.

Should I delete old out of stock variants completely?

If a variant is not coming back, it is cleaner to delete or hide it completely from the product. Use the out of stock view for short-term sales and seasons, not for variants that are permanently discontinued.

Do you need help? Contact us at support@shoporama.dk.