Ad
How To Retrieve Customer Email After Creating Order - Laravel & Shopify
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,
}
}
Ad
Answer
You can use:
$customer_email = $order['customer']['email'];
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad