I need a small help. How to pass the values to json with different values.

$params =   array( 'OrderLineId'=>$orderLineId,
$orderData = array('OrderId'=>$orderId,
                            'PartnerId'=>  $partnerId,
                            'CustomerId'=> $customerId,
                            'OrderType'=> $orderType,
                            'OrderSource'=>  $orderSource,
                            'CurrId'=> $currId,
                            'UserName'=> $userName);

I need to pass the values like

"OrderHeader": { "OrderId": "12", "StoreId": "main_website_store", "PartnerId": "15", "CustomerId": "16", "OrderType": "NEW", "OrderSource": "Megento", "CurrId": "USD", "UserName": "sdfdsfdsf" },
"OrderDetail": [ { "OrderLineId": "string", "MaterialNo": "79c29af7-3cd0-4a6f-b182-a81e31dec84e", "PlanType": "Anual","Qty": 0,"UnitPrice": 0.1, "UnitTax": 0.1,"DiscountRate": 0.1,"Discount": 0.1},{    "OrderLineId": "string", "MaterialNo": "BCESS876","PlanType": "Month","Qty": 2,"UnitPrice": 0.1,"UnitTax": 0.1,"DiscountRate": 0.1,"Discount": 0.1}]}

any one please help me.


Try this way:

$data = array(
    'OrderHeader' => $orderData,
    'OrderDetail' => array(
$json = json_encode($data);
|improve this answer|||||
  • once I get a success response from rest API then only place the order how to write the condition? – venkata prasad Feb 12 '18 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.