【发布时间】:2018-10-31 09:48:59
【问题描述】:
我已经在我的 shopify 应用中注册了我的 webhook,并且我能够从 webhook 接收到我指定地址的响应。
但是我现在想做的是,当我创建一个订单并将响应发送到指定地址时,我怎么get the ID of the order created?
我想在发送给客户的通知中包含order id?
PS:我是 laravel 和在 shopify 中创建应用程序的新手。
控制器
public function orderCreateWebhook(Request $request)
{
//get order_id here and send notification
notification = "A new order with id [order_id] has been
created";
SendSMS(notification);
}
public function registerOrderCreateWebhook(Request $request)
{
$shop = "example.myshopify.com";
$token = "xxxxxxxxxxxxxxxxxxxxxx";
$shopify = Shopify::setShopUrl($shop)->setAccessToken($token);
Shopify::setShopUrl($shop)->setAccessToken($token)->post("admin/webhooks.json", ['webhook' =>
['topic' => 'orders/create',
'address' => 'https://shop.domain.com/order-create-webhook',
'format' => 'json'
]
]);
}
网络
//register order create
Route::get('/register-order-create-webhook', 'AppController@registerOrderCreateWebhook');
Route::post('order-create-webhook', 'AppController@orderCreateWebhook');
【问题讨论】: