[eluser]RMinor[/eluser]
I had that at first. Here is my add method from my cart controller. Note that in this particular instance the 'free_nail' or 'free_tanktop' attribute will be TRUE, so the price gets reset as 0.00 (I have included comments where it happens). The error logs are telling me that the price is invalid.
Code:
public function add($options_to_check = array('color', 'size', 'free_nail', 'free_tanktop'))
{
$this->load->model('Cart_model');
if ($this->input->post('free_nail')) {
$price = 0.00; // price is set here
$this->session->set_userdata('free_nail', TRUE);
} elseif ($this->input->post('free_tanktop')) {
$price = 0.00; // price is set here
$this->session->set_userdata('free_tanktop', TRUE);
} else {
$price = $this->Cart_model->getProductPrice($this->input->post('id'));
}
$data = array(
'id' => $this->input->post('id'),
'name' => str_replace('/', '-',$this->input->post('name')),
'qty' => (int)$this->input->post('quantity'),
'price' => (float)$price
);
$options = array();
foreach($options_to_check as $option) {
if($this->input->post($option)) {
$options[$option] = str_replace('/', '-', $this->input->post($option));
}
}
if(count($options)) {
$data['options'] = $options;
}
if ($this->cart->insert($data)) {
if (!$this->input->is_ajax_request()) {
redirect('cart');
} else {
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('message' => 'TRUE', 'data' => $data)));
}
} else {
if ($this->input->is_ajax_request()) {
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('message' => 'FALSE', 'data' => $data)));
}
}
}