Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How do I pull a var from Sessions Table?


yomama360

Recommended Posts

Im fairly new to PHP.

 

I'm trying to set some functionality that needs to be based on what product is in the shopping cart. I figure the best way to do this is by pulling it from the value field of table sessions in the data base. But how do I pull a value from the session table? The products_id for example.

 

In the database I can see the "shoppingcart", "contents" and "qty" in the field called value (in the sessions table) along with tones of other stuff like user name and address. I can even see the products_id number, I just dont know how to query that info.

 

The end result will be on the checkout shipping page and will be something like this:

 

if (products_id == 3) {

do this; }

 

elseif (products_id == 4) {

do that; }

 

Thanks in advance

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself.

Therefore, all progress depends upon the unreasonable man."

-- George Bernard Shaw

Link to comment
Share on other sites

osC has the cart class that can be used here rather than trying to get data from the session table.

 

The following code should give you some idea:

 

$products = $cart->get_products();

while ($i=0; $i<sizeof($products); $i++) {
 if ($products[$i]['id] == 123) {
// do this thing for product_id 123
 } elseif ($products[$i]['id'] == 456) {
// do this for product_id 456
 }
}

 

Tom

Link to comment
Share on other sites

Brilliant, exactly what I was looking for.

 

For the record I ended up with something like this:

$products = $cart->get_products();
$i = 0;
while ($i<sizeof($products)) {
  $i++;
 if ($products[$i]['id] == 123) {
// do this thing for product_id 123
 } elseif ($products[$i]['id'] == 456) {
// do this for product_id 456
 }
}

Thanks Again

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself.

Therefore, all progress depends upon the unreasonable man."

-- George Bernard Shaw

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...