Hey Everyone,
Was wondering if theres anyone out there that could perhaps shed some light on a problem i'm currently having. I am currently using a heavily modified version of wfcart (a session based shopping cart) which works perfectly when adding single products.
What i want to do is enable the user to be able to upload a text file that will populate the shopping cart by reading each line from the supplied text file (tab or comma delimited).
The code i currently have is:
include "../include/wfcart.php";
session_start(); // start the session
$cart =& $SESSION['wfcart']; // point $cart to session cart.
if(!is_object($cart)) $cart = new wfCart(); // if $cart ( $SESSION['cart'] ) isn't an object, make a new cart
$filecontents = file("test.txt"); //open text file
for($x=0;$x<count($filecontents);$x++)
{
print "<BR>I'm now at record # ".$x;
$records = explode("\n\r",$filecontents[$x]);
foreach ($records as $record)
{
$product = explode(",",$record);
}
$cart->add_item('180.0425','Test',"0.00"," ");
}
This works ok and i can get it print each record without the $cart-> line in there. However as soon as i uncomment this line it halts on the second record and does not read any further and i am unsure as to why??
As you can see at the minute i'm just using fixed data to add to the cart at the minute this was just to proove that its not the contents of the variables i was passing to the cart that was throwing the code up.
Any suggestions would be greatly apreciated.
Hope your well!