从osCommerce shoppingCart对象检索购物车内容


Retrieve cart contents from the osCommerce shoppingCart object

如何从osCommerce中的shoppingCart对象提取或获取值?我想在主页上显示购物车的内容,所以我打印了当前会话以获得以下内容:

shoppingCart Object
(
    [contents] => Array
        (
            [32] => Array
                (
                    [qty] => 1
                )
            [26] => Array
                (
                    [qty] => 2
                )
        )
    [total] => 2960
    [weight] => 0
    [cartID] => 29022
    [content_type] => 
)

我想从contents数组中检索值。即:32个数量,总共26个数量,但我不知道如何操作,因为它使用的是"shoppingCart对象"。

Object内部有数组。

所以你可以做:

$contents = $shoppingCart['contents'];

以获取项目ID和数量。

如果你想要总数,做:

$contents = $shoppingCart['total'];