Jump to content

[SOLVED] Shopping Cart Data Parsing Question


Skor

Recommended Posts

???

I think I've exceeded my knowledge threshold. I'm in the process of integrating Mal's Shopping Cart with my site and am unsure of how to take data that is sent and use it to update my inventory.

 

One of the fields that is posted back is a field called cart. It includes all the items purchased in a single transaction. It looks something like this:

 

First product description:1:9.99:0:QX001~Second product description:2:8.99:0:QT0045

 

cart Each product is delimited by a ~ and description, quantity, price, shipping units,stock code by colons : Blob

 

What I'd like is basically a collection (an array?) of stock codes that will allow me to change the status of the codes in my data base through a relatively simple query-- change status to 'S' where code in ('QT0045','QX001').

 

My problem is that I more or less know what I want to do but am unsure in HOW to do it. I appreciate any guidance. Thanks.

 

does this help?

 


$cart = $_POST['cart'];

// breaks the string into an array of products
$products = explode("~", $cart);

$i = 0;

// breaks each product string into its own array
foreach($products as $var => $val){

  $product[$i] = explode(":", $val);
  $code = $product[$i][4];
  // if you want to update the status of codes, you can do it here
  // say you have a table named codes with code, status fields
  $update = "UPDATE codes SET `status`='S' WHERE `code`='$code'";
  mysql_query($update) or die(mysql_error());

  $i++;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.