I try to make a shipping method using Rajaongkir API, but I need to add some data to my database that contain the shipping cost <?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value'] ?>
but, it is always show an"0" in my database
this is my view
<?php echo form_open('orders/proceed'); ?>
<select class="form-control">
<option name="ongkir" selected="" disabled="">Pilih Layanan</option>
<?php
for ($l=0; $l < count($data['rajaongkir']['results'][$k]['costs']); $l++) {
?>
<?php echo "<option value='".$data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value']."'>" ?>
Layanan <?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['service'] ?> |
<?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['etd'] ?> Hari | Rp.
<?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value'] ?>
<?php "</option>"; ?>
<?php
}
?>
</select>
and this is the controller
$carts = $this->cart->contents();
$ongkir = $this->input->post('ongkir');
foreach ($carts as $item) {
$product = $this->Product->getProductByCode($item['id']);
$detail['code'] = $item['id'];
$detail['name'] = $item['name'];
$detail['price'] = $item['price'];
$detail['qty'] = $item['qty'];
$detail['discount_percent'] = $item['options']['discount_percent'];
$detail['net_price'] = $product['net_price'];
$detail['weight'] = $item['options']['weight'];
$detail['order_id'] = $orderId;
$detail['ongkir'] = $ongkir;
$this->Order_detail->create($detail);
}
this is the screenshot
I cannot add the shipping cost to my value. How to resolve it and and those shipping cost value to my database?