I want to post this array to website using curl, so I must convert it first to json. I used json_encode but I got the wrong format.
$inv=Array
("sales_invoice" => Array
(
"transaction_date" => $date,
"transaction_lines_attributes" => [ Array
(
"quantity" => 1,
"rate" => $price,
"discount" => 0,
"product_name" => "$ordersku",
"tax" => false
)],
"address" => "JL. Gatot Subroto 55, Jakarta, Jawa Barat, 11739",
"term_name" => "Net 30",
"deposit_to_name" => "Cash",
"warehouse_name" => "",
"due_date" => "$due2",
"shipping_date" => "$date",
"shipping_price" => "0.0",
"shipping_address" => "ship_address",
"is_shipped" => true,
"ship_via" => "jne",
"reference_no" => "$ordernumber",
"tracking_no" => "",
"deposit" => "0",
"person_name" => "Lazada",
"discount_type_name" => "Value",
"discount_unit" => 0,
"custom_id" => "",
"tax_name" => "Tax 0%",
"email" => "[email protected]",
"transaction_no" => "$orderitemid",
));
the json format must be like this
{\n \"sales_invoice\": {\n \"transaction_date\": \"2015-10-23\",\n \"transaction_lines_attributes\": [\n {\n \"quantity\": 1,\n \"rate\": 25000000,\n \"discount\": 0,\n \"product_name\": \"Sales\",\n \"tax\": true\n }\n ],\n \"address\": \"JL. Gatot Subroto 55, Jakarta, Jawa Barat, 11739\",\n \"term_name\": \"Cash_on_Delivery\",\n \"deposit_to_name\": \"Cash\",\n \"warehouse_name\": \"New Warehouse\",\n \"due_date\": \"2015-10-23\",\n \"shipping_date\": \"2016-09-15\",\n \"shipping_price\": \"0.0\",\n \"shipping_address\": \"ship_address\",\n \"is_shipped\": true,\n \"ship_via\": \"jne\",\n \"reference_no\": \"REF1\",\n \"tracking_no\": \"TR01\",\n \"deposit\": \"25000000\",\n \"person_name\": \"Per\",\n \"discount_type_name\": \"Value\",\n \"discount_unit\": 30000,\n \"custom_id\": \"SalesInvoice1\",\n \"tax_name\": \"PPN Tes\",\n \"email\": \"[email protected]\",\n \"transaction_no\": \"4SH4LFS\"\n }\n}";
Cheers
"$ordernumber"and"$orderitemid"strings of the values inside$ordernumberand$orderitemid, at the moment i'm assuming the latter