Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

In Stock/Out of Stock/Lead Time

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-17-2011, 08:18 AM
 
welly welly is offline
 

eXpert
  
Join Date: Mar 2011
Location: UK
Posts: 209
 

Default In Stock/Out of Stock/Lead Time

Hi,

Rather than showing stock levels on our product pages, I want to show whether a product is in stock, out of stock, or in some cases, what the expected dispatch time will be. Most of our products are 'standard, and we only want people to be able to order them if they are available. Some others we would like to be available to order all the time, even if we don't have them physically available at the time of the order.

I have added an extra product field, 'Leadtime', which for certain products will contain something like 'Usually dispatched within 21 days'. For those products, I have set the stock level to 100000 or similar.

In /common_files/customer/main/product_details.tpl I have added the following code just below where the stock levels would be shown:

<tr>
<td class="property-name">Availability</td>
<td class="property-value" colspan="2">
{if $product.avail gt 50000}
{foreach from=$extra_fields item=v}
{if $v.field eq "Leadtime"}
{$v.field_value}
{/if}
{/foreach}
{elseif $product.avail gt 0}
In Stock
{else}
Out of Stock
{/if}
</td>
</tr>

It probably isn't the neatest way to do it, but it does seem to do the trick for our standard products. If availability is > 50000 (special product) then show the leadtime, otherwise if it's >0 it's 'In Stock', if not it's 'Out of Stock'.

Unfortunately it doesn't work for products with variants. I have a product with 3 sizes and 2 colours (6 choices in all), and if I switch on the stock level setting, I can see that when I select between the various options, the stock levels and prices alter as they should, but my 'Availability' code doesn't update.

It does show 'In Stock' if any one of the variants is in stock, and 'Out of Stock' if none of them are, but that's about it.

Can anyone point me to the bit of code I need to be looking at, and give me a clue or two as to the changes I need to make? I'm looking at some of the Product_Options templates, and I'm not sure I want to be fiddling with them without a little direction.

Many thanks

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
  #2  
Old 04-27-2011, 05:43 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: In Stock/Out of Stock/Lead Time

In case of variants there is a special JS code that updates HTML on page as soon as the page is loaded.

Thus you should also make the necessary changes to the "skin/common_files/modules/Product_Options/func.js" script.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:41 AM.

   

 
X-Cart forums © 2001-2020