View Single Post
  #1  
Old 03-06-2015, 12:59 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Remove variant selections that are out of stock

Okay, you know I rarely ask questions, but this time I am stumped. I am trying to remove options from the select box when they are out of stock.

On the product page, we have attributes selections like size and color. We only want to show the options that are in stock. So I need to edit the template and add an if statement that calls a method and tells me if the selected variant is in stock.

The template I am working in is skins/default/en/product/attribute_value/select/body.tpl

Here is the default code:
Code:
<span class="title">{attribute.name}</span> <select class="form-control" name="{getName()}" data-attribute-id="{attribute.id}"> <option FOREACH="getAttrValue(),v" selected="{isSelectedValue(v)}" value="{v.id}">{getOptionTitle(v)}{getModifierTitle(v):h}</option> </select>

Likely I need to modify this template like so:
Code:
<span class="title">{attribute.name}</span> <select class="form-control" name="{getName()}" data-attribute-id="{attribute.id}"> {foreach:getAttrValue(),v} {if:isInStock(v)} <option selected="{isSelectedValue(v)}" value="{v.id}">{getOptionTitle(v)}{getModifierTitle(v):h}</option> {end:} {end:} </select>

But what I am struggling with is how to write the method "ifInStock()" and what class to put it in. Any help would be most appreciated. Tony?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote