View Single Post
  #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