2

How do I extract or get the value from the shoppingCart object in osCommerce? I want to display the cart contents on home page so I printed the current session to get the below:

shoppingCart Object
(
    [contents] => Array
        (
            [32] => Array
                (
                    [qty] => 1
                )

            [26] => Array
                (
                    [qty] => 2
                )

        )

    [total] => 2960
    [weight] => 0
    [cartID] => 29022
    [content_type] => 
)

From this I want to retrieve the values from the contents array. i.e.: 32 qty, 26 qty and total, but I don't know how to because it's using a "shoppingCart Object".

random
  • 9,774
  • 10
  • 66
  • 83
devkann
  • 79
  • 1
  • 12
  • 1
    possible duplicate of [Get specific value from Object in PHP](http://stackoverflow.com/questions/3122793/get-specific-value-from-object-in-php) – random Mar 09 '12 at 06:00

1 Answers1

1

Inside the Object there are arrays.

So you can do:

$contents = $shoppingCart['contents'];

to get the itemid and qty.

if you want the total, do:

$contents = $shoppingCart['total'];
Andrew Hall
  • 3,058
  • 21
  • 30