0

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

$params =   array( 'OrderLineId'=>$orderLineId,
                            'MaterialNo'=>$materialNo,
                            'PlanType'=>$planType,
                            'Qty'=>$qty,
                            'UnitPrice'=>$unitPrice,
                            'UnitTax'=>$UnitTax,
                            'DiscountRate'=>$DiscountRate,
                            'Discount'=>$Discount);
$orderData = array('OrderId'=>$orderId,
                            'StoreId'=>$storeId,
                            '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.

0

Try this way:

$data = array(
    'OrderHeader' => $orderData,
    'OrderDetail' => array(
        $params
    )
);
$json = json_encode($data);
  • 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.