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

Strange Out Of Stock Behavior on Products page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-08-2009, 05:42 PM
 
birdman birdman is offline
 

Member
  
Join Date: Jan 2007
Location: Sydney, Australia
Posts: 13
 

Default Strange Out Of Stock Behavior on Products page

I have a fashion site with variants on most products. I display SOLD OUT on the product page, and on the products (category) page when a product is out of stock, for the most part this works. I have the following code in products.tpl to handle this:
Code:
{if $products[product].avail le 0}<div class="sellout">SOLD OUT</div>{/if}
My problem comes when a user puts the last available item for the first variant in their cart, the product also appears as SOLD OUT on my products (category) page. It only appears this way to the customer with the product in their cart. So, say I have a dress in size 6,8 and 10, if there is one size 6 left and a customer puts it in their cart, the product then appears to the customer as sold out in the products list (category pages) regardless of the availability of the other sizes. This freaks customers out as they then become uncertain of a product's availability, and perhaps don't follow through.

My question (finally) how can I change this behavior so it only says SOLD OUT in my product listings if ALL variants are SOLD OUT, not just when someone has the last one of something in their cart?

I realise the importance of the default functionality on the product page, to prevent someone adding unavailable stock to their cart, but on the category pages it is confusing, especially when other variants might still be available.

Thanks in advance.
__________________
birdman
X-Cart Gold 4.1.8
Unix FreeBSD | MySQL 4.1.22 | PHP 5.2.10
Reply With Quote
  #2  
Old 06-08-2009, 07:30 PM
 
birdman birdman is offline
 

Member
  
Join Date: Jan 2007
Location: Sydney, Australia
Posts: 13
 

Default Re: Strange Out Of Stock Behavior on Products page

Okay, so I think I've found where I can fix this strange behavior but am wondering if anyone can think of any adverse consequences of doing this.

In include/search.php there is the following code:
Code:
$in_cart = 0; if (!empty($cart['products']) && is_array($cart['products'])) { # Modify product's quantity based the cart data foreach ($cart['products'] as $cv) { if ($cv['productid'] == $v['productid'] && intval($v['variantid']) == intval($cv['variantid'])) $in_cart += $cv['amount']; } $products[$k]['in_cart'] = $in_cart; $products[$k]['avail'] -= $in_cart; if ($products[$k]['avail'] < 0) { $products[$k]['avail'] = 0; } }

When I comment out the line:
Code:
$products[$k]['avail'] -= $in_cart;
like so:
Code:
//$products[$k]['avail'] -= $in_cart;

then it prevents the behavior I'm talking about.

Can anyone think of any other consequences of doing this?
__________________
birdman
X-Cart Gold 4.1.8
Unix FreeBSD | MySQL 4.1.22 | PHP 5.2.10
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 12:36 PM.

   

 
X-Cart forums © 2001-2020