我正在尝试在成功将商品输入购物车后构建购物车系统。如何根据商店展示商品。我在这里有点受限制。
控制器
function to_cart () {
$data = array(
array(
'id' => '1',
'qty' => 1,
'price' => 2.400,
'name' => 'Asus Eeepc',
'store' => 'My_store 1'
),
array(
'id' => '2',
'qty' => 1,
'price' => 1.500,
'name' => 'Accer AspireOne',
'store' => 'My_store 1'
),
array(
'id' => '3',
'qty' => 1,
'price' => 4.000,
'name' => 'Toshiba Satelite',
'store' => 'My_store 2'
),
array(
'id' => '4',
'qty' => 1,
'price' => 2.700,
'name' => 'Lenova ThinkCare',
'store' => 'My_store 1'
)
);
$this->cart->insert($data);
redirect($this->agent->referrer());
}
浏览
<?php foreach ($this->cart->contents() as $item) {
echo '<td>'.$item['no'].'</td>';
echo '<td>'.$item['name'].'</td>';
echo '<td>'.$item['price'].'</td>';
echo '<td>'.$item['qty'].'</td>';
echo '<td>'.$item['store'].'</td>';
?>