php - 创建订单后如何检索客户电子邮件 - Laravel & Shopify
问题描述
当我创建订单时,我的 web-hook 会向我的控制器返回一个响应,下面是我如何检索订单的详细信息
控制器
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'];
}
在我的控制器中,我能够检索到,order_id, order_total
但我无法获得下订单的客户的电子邮件。
我的代码有什么问题?
这是 Shopify 的响应的样子
回复
{
"id": 820982911946154508,
"email": "jon@doe.ca",
"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": "john@test.com",
"accepts_marketing": false,
"created_at": null,
}
}
解决方案
您可以使用:
$customer_email = $order['customer']['email'];
推荐阅读
- css - SVG 两路一球动画
- java - Bazel - 获取当前操作系统和 CPU 类型作为要在构建规则中使用的变量
- regex - 使用正则表达式搜索具有相似结构的字符串
- angular - 在路由模块 Angular 4 中调用服务
- angular - 确认密码未在角度材料中验证
- azure-cosmosdb - ReactiveMongo|CosmosDb:如何使用 ReactiveMongo 使用 URI 连接到 Cosmos Db
- javascript - Reactjs 身份验证/授权
- r - 生成与一个向量相关但彼此之间不相关的随机变量
- node.js - 从流中读取时的NodeJs可读错误
- firebase - 类型错误:将图像从本机反应上传到firebase时网络请求失败