我正在尝试使用Codeigniter的购物车。 我的模型中有可用产品列表。但是,当我尝试将其添加到购物车时,没有添加任何内容。我怀疑是因为我没有正确退回产品。
这是我的模特:
function getHolidayTVProducts() {
return array(
'TVHOL_1000' => array('id' => 'TVHOL_1000', 'qty' => 1, 'price' => 148.50, 'name' => '1,000 to 20,000 - $148.50 USD'),
'TVHOL_20000' => array('id' => 'TVHOL_20000', 'qty' => 1, 'price' => 178.50, 'name' => '20,000 to 30,000 - $178.50 USD'),
'TVHOL_30000' => array('id' => 'TVHOL_30000', 'qty' => 1, 'price' => 208.50, 'name' => '30,000 to 40,000 - $208.50 USD'),
'TVHOL_40000' => array('id' => 'TVHOL_40000', 'qty' => 1, 'price' => 238.50, 'name' => '40,000 to 50,000 - $238.50 USD'),
'TVHOL_50000' => array('id' => 'TVHOL_50000', 'qty' => 1, 'price' => 268.50, 'name' => '50,000 to 60,000 - $268.50 USD'),
'TVHOL_60000' => array('id' => 'TVHOL_60000', 'qty' => 1, 'price' => 298.50, 'name' => '60,000 to 70,000 - $298.50 USD'),
'TVHOL_70000' => array('id' => 'TVHOL_70000', 'qty' => 1, 'price' => 0, 'name' => 'Over 70,000 - Please call')
);
}
// Function returns an array containing a specific product ID
function getHolidayTVProduct($productID) {
$array = $this->getHolidayTVProducts();
return $array[$productID];
}
获取产品似乎不是问题。这是我的控制者:
$holiday_products = $this->products->getHolidayTVProducts();
$holiday_tv_available_products = array('Select Your Circulation'); //placeholder text
foreach ($holiday_products as $key => $item) {
$holiday_tv_available_products[$key] = $item['name'];
}
$data['products_TVHoliday'] = $holiday_tv_available_products;
if ($this->form_validation->run() == FALSE) {
$this->load->view('templates/header.php', $header);
$this->load->view('printmedia/holiday', $data);
$this->load->view('templates/modal.php');
$this->load->view('templates/footer.php');
}
else {
$selected_product = $this->products->getHolidayTVProduct($this->input->post('products_TVHoliday'));
echo $selected_product;
}
if ($this->form_validation->run() == TRUE) {
$products_ID = $this->products->getHolidayTVProduct($this->input->post('products_TVHoliday'));
$selected_product = $products_ID;
$this->cart->insert($selected_product);
从我看来。
<?php echo form_open('printmedia/themed/holiday-tv'); ?>
<?php echo form_dropdown('products_TVHoliday', $products_TVHoliday, '', 'class="span6"'); ?>
</div>
<div id="winterOrder" class="row-fluid">
<p><!--Place Special Ordering form here --></p>
</div>
<div class="row-fluid">
<?php echo form_submit('processorder', 'Process Order', 'class="btn btn-inverse"');?>
<?php echo form_close();?>
答案 0 :(得分:0)
问题在于产品名称中的特殊字符:
50,000 to 60,000 - $268.50 USD
删除dolar标志和逗号后添加到卡片。
50 000 to 60 000 - 268.50 USD