我的购物车会议中有2件商品。并希望我在数组 data_order 中合并。但只读一个产品。实际上我将通过电子邮件发送这些数据,因此我制作了这样的数据格式。
我的控制员:
foreach ($this->cart->contents() as $item){
if($item['diskon'] == "0"){
$harga_before = $item['before'];
$harga_after = $item['price'];
}else{
$harga_before = $item['before'];
$harga_after = $item['price'];
}
foreach ($this->cart->product_options($item['rowid']) as $option_name => $option_value){
if(empty($option_value)){
$option_size = "";
$option_color = "";
}else{
$option = $item['options'];
$option_size = $option['Size'];
$option_color = $option['Warna'];
}
}
$data = array(
'inv' => $invoice,
'tglOrdercs' => date('d F Y H:i:s'),
'tglExp' => $date_maju,
'nmlkp' => $nmlkpi,
'almtkp' => $address,
'noTelp' => $notelp271,
'methode' => $method,
'bnk_option' => $banking_select,
'data_order' => array(
'nama_produk' => $item['name'],
'artikel' => $item['artikel'],
'diskon' => $item['diskon'],
'ukuran' => $option_size,
'warna' => $option_color,
'qty' => $item['qty'],
'harga_fix' => $harga_after,
'harga_before' => $harga_before,
),
);
}
我的结果:
Array(
[inv] => STJOHB9261JR
[tglOrdercs] => 28 September 2017 11:23:33
[tglExp] => 28 September 2017 21:23:33
[nmlkp] => danny setyawan
[almtkp] => Perum puspa sari H22 sidoarjo
[noTelp] => 089263423647
[methode] => Transfer
[bnk_option] => Bank BNI
[data_order] => Array
(
[nama_produk] => Sonic TL Brown
[artikel] => CH2002-831
[diskon] => 40
[ukuran] => 39
[warna] => Coklat
[qty] => 2
[harga_fix] => 125340
[harga_before] => 208900
)
)
忽略“>”,这是浏览器控制台的结果。