我将所有产品详细信息存储到会话变量购物车中,并将新添加的产品详细信息存储在数组new中。这些细节合并在一起,我有一个像这样的数组
Array(
[0] => Array(
[0] => Array
(
[product_id] => 2
[length_id] => 1
[length] => 12"
[color] => Black , Natural Black
[quantity] => 345
[image] => http://localhost/shopping_cart/shop/uploads/product/deepwave.jpg
[totalprice] => 1500
[pdt_name] => Deep Wavy
[pdt_description] => Lorem Ipsum is simply dummy text of the printing and typesetting industry.
[pdt_image] => deepwave.jpg
)
)
[1] => Array
(
[product_id] => 3
[length_id] => 1
[length] => 12"
[color] => Black , Natural Black
[quantity] => 234
[image] => http://localhost/shopping_cart/shop/uploads/product/loose wavy.jpg
[totalprice] => 2500
[pdt_name] => Loose Wavy
[pdt_description] => Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
[pdt_image] => loose wavy.jpg
)
)
答案 0 :(得分:0)
在控制器中获取会话变量,并使用for循环来迭代它。
$product_details = $this->session->userdata('cart');
foreach($product_details as $item){
echo $item['product_id']; /* likewise use for each field you need. */
}