Código PHP:
Espero que me puedan ayudar.Ver original
public function savePedido($cli, $tot, $fec, $est) { $this->db->trans_start(); 'fecha' => $fec, 'cliente' => $cli, 'total' => $tot, 'estado' => $est ); $this->db->insert('pedidos', $dataSave); $pedido = 0; $this->db->select_max('codigo', 'cod_ped'); $q = $this->db->get('pedidos'); $r = $q->result(); foreach ($r as $row) { $pedido = $row->cod_ped; } $i = 1; foreach ($this->cart->contents() as $items) { $qty = $items['qty']; $pro = $items['id']; $i = 0; foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value) { $opt[$i] = $option_value; $i++; } $ing = $opt[0]; 'pedido' => $pedido, 'cantidad' => $qty, 'producto' => $pro, 'ingredientes' => $ing ); $this->db->insert('pedidos_detalles', $dataDeta); } $this->db->trans_complete(); if ($this->db->trans_status() === false) { return false; } else { return true; } }
Gracias,