简体   繁体   中英

Retrieve cart contents from the osCommerce shoppingCart object

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. ie: 32 qty, 26 qty and total, but I don't know how to because it's using a "shoppingCart Object".

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'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM