X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Show variant "out of stock" on dropdown (https://forum.x-cart.com/showthread.php?t=68242)

proboscidian 11-30-2013 08:17 PM

Show variant "out of stock" on dropdown
 
I am trying to show "out of stock" on the dropdown list for any variant that is not in stock. The products have only one variant; all other options are price modifiers. This is for a 4.6.1 x-cart. Does anyone have any ideas? If I have to I will just write it out on each dropdown, but it would be better if it was automatic.

cherie 12-03-2013 05:57 PM

Re: Show variant "out of stock" on dropdown
 
Here is some old code that might at least point you in the right direction ("oos" is out of stock):
PHP Code:

{foreach from=$p.product_options item=v}
  {foreach 
from=$v.options item=o}
    {
assign var=oos value=0}
    {if 
$p.variants}
      {foreach 
from=$p.variants item=var}
        {foreach 
from=$var.options key=void item=vop}
          {if 
$void eq $o.optionid}
            {if 
$var.avail lt 1}
              {
assign var=oos value=1}
            {else}
              {
assign var=oos value=0}
            {/if}
          {/if}
        {/foreach}
      {/foreach}
    {/if} 

Then you can use the "oos" flag on the drop down to add a message or disable it. Here is an example:
PHP Code:

<option value="{$o.optionid}"{if $o.selected eq 'Y'selected="selected"{/if}{if $oosdisabled="disabled"{/if}>{if $oos}out of stock{/if} 



All times are GMT -8. The time now is 04:05 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.