我尝试使用Rajaongkir API制作送货方式,但我需要在数据库中添加一些包含运费<?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value'] ?>
的数据
但是,我的数据库中始终显示“0”
这是我的观点
<?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>
这是控制器
$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);
}
这是截图
我无法将运费添加到我的价值中。 如何解决它以及那些运费成本值到我的数据库?