When i create an order, my web-hook returns a response to my controller and below is how i retrieve the details of the order
Controller
public function getOrderDetails()
{
// get the content of request body
$order = $request->getContent();
$order = json_decode($order, true);
$order_id = $order['number'];
$order_total = $order['total_price'];
$customer_email = $order['customer.email'];
}
As in my controller, i am able to retrieve the order_id, order_total
but i am not able to get the email of the customer who placed the order.
What is wrong in my code ?
This is how the response looks like from Shopify
Response
{
"id": 820982911946154508,
"email": "[email protected]",
"closed_at": null,
"created_at": "2018-10-26T13:55:26-04:00",
"updated_at": "2018-10-26T13:55:26-04:00",
"number": 234,
"note": null,
"customer": {
"id": 115310627314723954,
"email": "[email protected]",
"accepts_marketing": false,
"created_at": null,
}
}
2
Answers
You can use:
1) Your json data has an error. You should remove comma(,) before }
2) Below code works correctly