Reputation: 121
i have a JSon Array, and i would like to add (not edit) values, but when i try to add it, i get a fatal error.
Here is my code:
Error happens on the first $ext_data['order']['lang_iso']=$lang->iso_code;
$ext_order = array(
"order" => $order,
"order_detail" => getList($order->id),
"order_messages" => Message::getMessagesByOrderId($order->id),
"customer" => $customer,
"address_delivery" => $address_delivery,
"address_invoice" => $address_invoice,
"iso_codes" => $iso_codes,
);
$ext_data = json_encode($ext_order, JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR);
$ext_data['order']['lang_iso']=$lang->iso_code;
$ext_data['order']['carrier_name']=$carrier->name;
$ext_data['order']['ccurrency_iso']=$currency->iso_code;
$ext_data['customer']['lang_iso']=$lang_customer->iso_code;
$ext_data['address_delivery']['country_iso']=Country::getIsoById($address_delivery->id_country);
$ext_data['address_delivery']['state_iso']=$state_delivery->iso_code;
$ext_data['address_invoice']['country_iso']=Country::getIsoById($address_invoice->id_country);
$ext_data['address_invoice']['state_iso']=$state_invoice->iso_code;
Upvotes: 1
Views: 90
Reputation: 2653
$order = json_decode(json_encode($order), true);
$ext_order = array(
"order" => $order,
"order_detail" => getList($order->id),
"order_messages" => Message::getMessagesByOrderId($order->id),
"customer" => $customer,
"address_delivery" => $address_delivery,
"address_invoice" => $address_invoice,
"iso_codes" => $iso_codes,
);
$ext_order['order']['lang_iso']=$lang->iso_code;
$ext_order['order']['carrier_name']=$carrier->name;
$ext_order['order']['ccurrency_iso']=$currency->iso_code;
$ext_order['customer']['lang_iso']=$lang_customer->iso_code;
$ext_order['address_delivery']['country_iso']=Country::getIsoById($address_delivery->id_country);
$ext_order['address_delivery']['state_iso']=$state_delivery->iso_code;
$ext_order['address_invoice']['country_iso']=Country::getIsoById($address_invoice->id_country);
$ext_order['address_invoice']['state_iso']=$state_invoice->iso_code;
$ext_data = json_encode($ext_order, JSON_PRETTY_PRINT | JSON_PARTIAL_OUTPUT_ON_ERROR); // changed the order.
Upvotes: 2