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

allowing orders of out of stock items?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 12-10-2004, 10:44 AM
 
CountyPaintball CountyPaintball is offline
 

Newbie
  
Join Date: Dec 2004
Location: NJ
Posts: 8
 

Default

I'm working on the same thing with very little success so far.

I've been able to show that a product is "out of stock" but still display the add_to_cart button. The problem is, as soon as it adds to the cart, some other script is seeing out of stock products in the cart and deleting them, then showing a "product expired" message.

If I get any further, I'll let you know. If anyone else can at least identify all the files that need changing for this mod, I'd appreciate it.

So far I've changed
/customer/cart.php
/skin1/customer/main/product.tpl

In my opinion, this should be a simple config option in x-cart where you can either allow out of stock purchases or not. It's the one non-feature keeping me from being completely satisfied with x-cart.
__________________
Mike Everland
CountyPaintball.com
Reply With Quote
  #12  
Old 12-10-2004, 05:13 PM
 
CountyPaintball CountyPaintball is offline
 

Newbie
  
Join Date: Dec 2004
Location: NJ
Posts: 8
 

Default

I have what looks like a solution.

Note: This is not thoroughly tested. Make any changes at your own risk. Be sure to make backups of your files before changing anything.

The change required 3 file updates:

/skin1/customer/main/product.tpl
This displays the product info. You need to avoid having it write "OUT OF STOCK" where you want the qty and add to cart button.
Near line 92 you'll see code that looks like this:
{if $config.General.unlimited_products eq "Y" or ($product.avail gt 0 and $product.avail ge $product.min_amount)}

You'll want to comment that line out as well as the resulting {/if} around line 111.

Be careful and count your "if" "/if" to make sure you get the correct pairing.

Move the code that displays "OUT OF STOCK" further up beneath the product details. It's your choice where to put it. I put it below the pricing info. This will let a customer know that there's an extra delay with this product, but they can still order it. You could also remove that code completely if you choose.
The "OUT OF STOCK" code looks something like this:
<tr><td>
{if $config.General.unlimited_products eq "N" and ($product.avail le 0 or $product.avail lt $product.min_amount)}
{$lng.txt_out_of_stock}
{/if}
</td></tr>

/customer/cart.php
Near line 150, you'll need to comment out 3 lines. They look like this:
if ($config["General"]["unlimited_products"]=="N" && $added_product["product_type"]!="C")
if ($amount > $added_product["avail"])
$amount = $added_product["avail"];

Near line 284, you need to fix the "$amount_max" so you won't have your item immediately disappear from the cart once you add it.
I added "$amount_max=100;" below the following:

if ($config["General"]["unlimited_products"]=="N" || $cart["products"][$productindex]["product_type"] == "C")
$amount_max=array_pop(func_query_first("select avail from $sql_tbl[products] where productid='$productid'"));
else
$amount_max=$updates_array[$productindex]["total_quantity"]+1;

Adding that line of code basically makes the lines above a waste, but I didn't want to delete those lines in case I need to change back. Also, setting to a hard-coded 100 is not considered good programming, but it seems to get the job done.

Finally:
/customer/func.php
In the following line, (near 1949)
$products_array = func_query_first("select $sql_tbl[products].*, min($sql_tbl[pricing].price) as price from $sql_tbl[products], $sql_tbl[pricing] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[products].productid='$productid' and $avail_condition $sql_tbl[pricing].quantity<=$amount and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') group by $sql_tbl[products].productid order by $sql_tbl[pricing].quantity desc");

Remove the phrase "$avail_condition" so it will not perform that check anymore. The new line should look like this:
$products_array = func_query_first("select $sql_tbl[products].*, min($sql_tbl[pricing].price) as price from $sql_tbl[products], $sql_tbl[pricing] where $sql_tbl[pricing].productid=$sql_tbl[products].productid and $sql_tbl[products].productid='$productid' and $sql_tbl[pricing].quantity<=$amount and ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') group by $sql_tbl[products].productid order by $sql_tbl[pricing].quantity desc");

Now, I repeat - this has not been thoroughly tested but it seems to work so far. I don't know if it will cause any new problems down the road so keep your backups handy. If you do find a problem with this method, please let me know. If I find any problems or better methods, I will post them here.

Thank you.
__________________
Mike Everland
CountyPaintball.com
Reply With Quote
  #13  
Old 01-21-2005, 09:00 AM
  CC's Avatar 
CC CC is offline
 

eXpert
  
Join Date: Jun 2004
Posts: 349
 

Default

Hi Mike

Did you ever find any problems with this approach?
Or does everything work smoothly?

This should be a simple solution really as you show, it only involves a few files.

I wouldn't mind know if you found this successful...

Cheers
__________________
XC 4.2 inc (unofficial) patch release.
Reply With Quote
  #14  
Old 01-21-2005, 09:19 AM
 
CountyPaintball CountyPaintball is offline
 

Newbie
  
Join Date: Dec 2004
Location: NJ
Posts: 8
 

Default

So far it's been fine. I'm still in development/testing but I haven't found any problems with the changes.
__________________
Mike Everland
CountyPaintball.com
Reply With Quote
  #15  
Old 01-21-2005, 09:45 AM
  CC's Avatar 
CC CC is offline
 

eXpert
  
Join Date: Jun 2004
Posts: 349
 

Default

Excellent, in which case we will give it a go.
I'll come back here and let ppl know how we got on with it also.

Thanks for the reply.
__________________
XC 4.2 inc (unofficial) patch release.
Reply With Quote
  #16  
Old 01-24-2005, 01:10 PM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default We have done this...

Just an FYI - - our company created a mod to do this, but a little more advanced.

It allows users to purchase as many items as they want - but tells them in their cart (also displays inventory accurately) how many items are on backorder and how many are in-stock. It then only charges them for the items that are in - stock - splitting the order into a regular order and one with a status of BO that has all of the BO items in it.

Then, in the backend, we have a "ship" button on all BO'ed orders - so you can choose to ship 12 of the 14 BO'ed items, and charge them automatically (assuming they paid with CC or E-check) for the items you just shipped, and send them a receipt.

This isn't a "free" mod and actually took months to develop correctly, but it works flawlessly now - recalculates shipping/tax and takes into consideration all of the little things...

Don't know if there is interest - and it may be more expensive than what x-cart is trying to do - but wanted to let you know it can be done...

Instinctual
Colorado
X-Cart Versions 3.5.x - 4.0.x
Reply With Quote
  #17  
Old 01-24-2005, 01:16 PM
  CC's Avatar 
CC CC is offline
 

eXpert
  
Join Date: Jun 2004
Posts: 349
 

Default

Hi

I know I have mentioned this to you before, that this is something that would be great for us to implement into our site, I just cant get full agreement from our Directors that the cost outweighs the benefits.

If the cost ever comes down a tad, please let me know.
Any ammo I can use to have this implemented would be great to go to all the Directors with.
__________________
XC 4.2 inc (unofficial) patch release.
Reply With Quote
  #18  
Old 02-14-2005, 04:34 PM
  DogByteMan's Avatar 
DogByteMan DogByteMan is offline
 

X-Adept
  
Join Date: Mar 2003
Posts: 833
 

Default

Quote:
Originally Posted by CountyPaintball
/customer/cart.php
Near line 150, you'll need to comment out 3 lines. They look like this:
if ($config["General"]["unlimited_products"]=="N" && $added_product["product_type"]!="C")
if ($amount > $added_product["avail"])
$amount = $added_product["avail"];

Near line 284, you need to fix the "$amount_max" so you won't have your item immediately disappear from the cart once you add it.
I added "$amount_max=100;" below the following:

if ($config["General"]["unlimited_products"]=="N" || $cart["products"][$productindex]["product_type"] == "C")
$amount_max=array_pop(func_query_first("select avail from $sql_tbl[products] where productid='$productid'"));
else
$amount_max=$updates_array[$productindex]["total_quantity"]+1;

Adding that line of code basically makes the lines above a waste, but I didn't want to delete those lines in case I need to change back. Also, setting to a hard-coded 100 is not considered good programming, but it seems to get the job done.


Can't get this part to work for me... Cart always comes up empty.

Given that below is listed the appropriate portion of code from cart.php - X-Cart 4.0.7:
Code:
# # Add to cart amount of items that is not much than in stock # if ($config["General"]["unlimited_products"]=="N" && $added_product["product_type"]!="C") if ($amount > $added_product["avail"]) $amount = $added_product["avail"]; if ($productid && $amount) { if ($amount < $added_product["min_amount"]) { func_header_location ("error_message.php?access_denied&id=31"); } $found = false; $product_distribution = func_query_first_cell("SELECT distribution FROM $sql_tbl[products] WHERE productid='$productid'"); if (!empty($cart) and @$cart["products"] and $added_product["product_type"]!="C") { foreach ($cart["products"] as $k=>$v) { if (($v["productid"] == $productid) && (!$found) && ($v["options"] == $product_options) && empty($v["hidden"])) { if ($v["free_price"] != $price) continue; $found = true; if (($cart["products"][$k]["amount"] >=1) && !empty($product_distribution)) { $cart["products"][$k]["amount"]=1; $amount=0; } $cart["products"][$k]["amount"] += $amount; } } } if (!$found) { # # Add product to the cart # if (!empty($price)) # price value is defined by customer if admin set it to '0.00' $free_price = abs(doubleval($price)); $cartid = func_generate_cartid($cart["products"]); if(empty($cart["products"])) $add_to_cart_time = time(); $cart["products"][]=array("cartid"=>$cartid, "productid"=>$productid,"amount"=>$amount, "options"=>$product_options, "free_price"=>@price_format(@$free_price),"distribution"=>$product_distribution); if(!empty($active_modules["Product_Configurator"])) include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php"; } $intershipper_recalc = "Y"; } elseif($from == 'partner' && $productid) { func_header_location($xcart_catalogs['customer']."/product.php?productid=".$productid); } } # # DELETE PRODUCT FROM THE CART # if ($mode=="delete" && $productindex!="") { # # Delete product from cart # if(!empty($active_modules["Product_Configurator"])) include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php"; foreach ($cart["products"] as $k=>$v) if ($v["cartid"] == $productindex) { $productid = $v["productid"]; if(!empty($active_modules["Advanced_Statistics"])) @include $xcart_dir."/modules/Advanced_Statistics/prod_del.php"; array_splice($cart["products"],$k,1); break; } $intershipper_recalc = "Y"; func_header_location("cart.php"); } elseif (!empty($shippingid)) { $cart["shippingid"]=$shippingid; } if (empty($action)) $action = ""; # # UPDATES PRODUCTS QUANTITY IN THE CART # if ($action=="update" && !empty($productindexes)) { # # Update quantity # foreach($productindexes as $_cartid=>$new_quantity) { foreach ($cart["products"] as $k=>$v) if ($v["cartid"] == $_cartid) { $productindexes_tmp[$k] = $new_quantity; break; } } $productindexes = $productindexes_tmp; unset($productindexes_tmp); if(!empty($active_modules["Product_Configurator"])) include $xcart_dir."/modules/Product_Configurator/pconf_customer_cart.php"; foreach($cart["products"] as $k=>$v) { $tot = 0; $tot_amount = 0; foreach($productindexes as $productindex=>$new_quantity) { if (!is_numeric($new_quantity)) continue; if ($cart["products"][$productindex]["productid"] == $v["productid"]) $tot += floor($new_quantity); } foreach($cart["products"] as $k2 => $v2) { if ($v["productid"] == $v2["productid"]) $tot_amount += $v2['amount']; } $updates_array[$k] = array("quantity"=>$v["amount"], "total_quantity"=>$tot, "total_amount" => $tot_amount); } # Create hash array with variants $hash = array(); if(!empty($active_modules['Product_Options'])) { foreach($productindexes as $productindex => $new_quantity) { if(!empty($cart["products"][$productindex]['options'])) { $variantid = func_get_variantid($cart["products"][$productindex]['options']); if($variantid) { if(!isset($hash[$variantid])) { $hash[$variantid]['avail'] = func_get_options_amount($cart["products"][$productindex]['options'], $cart["products"][$productindex]['productid']); } $hash[$variantid]['old'] += $cart["products"][$productindex]['amount']; $hash[$variantid]['new'] += $new_quantity; $hash[$variantid]['ids'][] = $cart["products"][$productindex]['productid']; $cart["products"][$productindex]['variantid'] = $variantid; } } } } # Check&set new quantity foreach($productindexes as $productindex => $new_quantity) { if (!is_numeric($new_quantity) || empty($cart["products"][$productindex])) continue; $new_quantity = floor($new_quantity); $productid=$cart["products"][$productindex]["productid"]; $total_quantity = $updates_array[$productindex]["total_quantity"]; $total_amount = $updates_array[$productindex]["total_amount"]; if ($config["General"]["unlimited_products"]=="N" && $cart["products"][$productindex]["product_type"] != "C") if(!empty($cart["products"][$productindex]['variantid'])) { $amount_max = $hash[$cart["products"][$productindex]['variantid']]['avail']; $total_quantity = $hash[$cart["products"][$productindex]['variantid']]['old']; } else { $amount_max=func_query_first_cell("select avail from $sql_tbl[products] where productid='$productid'"); } else $amount_max=$total_quantity+1; $amount_min=func_query_first_cell("select min_amount from $sql_tbl[products] where productid='$productid'");

Anyone know how I can keep the cart from seeing 0 stock and delivering an empty cart?

Is it the EzCheckout and EzUpsell mods I have installed causing the original mod not to work?
__________________
Dedicated Server provided by EWD Hosting
X-Cart version 4.1.12
PHP 5.3.2
MySQL server 5.0.87-community
Operation system Linux
Perl 5.008008
dogbytecomputer.com
Reply With Quote
  #19  
Old 03-07-2005, 06:12 PM
  1CNS's Avatar 
1CNS 1CNS is offline
 

Advanced Member
  
Join Date: Mar 2004
Location: Los Angeles, CA, USA
Posts: 45
 

Default

I just wanted to rave a little about the mod that instinctual describes above. It needs to be made widely available somehow, preferable in a way where you can recover some or all of your apparently substantial investment. It would be great if you could sell your code to X-Cart who could re-package it as an add-on (or as a distant second, you might work through one of the after-market companies selling X-Cart add-ons and mods). This would likely create the kind of economies of scale that would allow this mod to be priced within reach (that is, hopefully less than X-Cart itself).

For my stores, this feature would fall squarely in the category of "Oh my God - how did I get along before this?". Under X-Cart's current inventory tracking system, the dilemma of whether to track or not to track is major for my business. Easily the leading source of time-consuming manual changes are orders with, say, 10 items and one $2.45 item missing. We don't back-order something like that, so we need to go in and modify the order to drop the item. We also don't capture CC transactions automatically when orders are placed (just authorize) because of orders like that. We'd always be issuing tiny credits. But this then creates a whole second manual step of charging each order, so we can get the right totals in for orders that are short. X-Cart's poor (essentially non-existent) integration with payment gateways greatly compounds this problem. That is, changing the order in X-Cart does not change the information with payment gateway, so there's another manual step there in changing the number. And X-Cart does not offer a direct interface with the gateway, meaning you're on two websites to do all this (Yahoo Store, for comparison, has a fully integrated payment gateway as part of its backend, bypassing this problem. But then they're much more expensive than X-Cart).

If we used X-Cart inventory tracking and charged CC orders automatically when they're placed, that would solve all of that hassle. But then we'd lose out on big orders that exceed stock. Last year someone ordered 200 items that retail for about $20 each. We had the stuff drop-shipped and everyone was happy, but that order would have been lost using X-Cart inventory tracking, since it exceeded our stock on hand.

Rave over. Good luck instinctual (or similarly inspired coders).
__________________
www.funkymart.com
x-cart 4.2.1 [linux]
Reply With Quote
  #20  
Old 03-07-2005, 06:28 PM
 
instinctual instinctual is offline
 

eXpert
  
Join Date: Nov 2003
Posts: 247
 

Default

Why don't you all PM me with contact info, etc. and we'll talk about what can be done...I'm sure something could be worked out. There are some things that would need to be done to get it up to speed with the 4.0.12 branch as well...just FYI.

Instinctual
Colorado
X-Cart Versions 3.5.x - 4.0.x
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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:23 AM.

   

 
X-Cart forums © 2001-2020