如何从 WooCommerce 中的 webhook 获取客户的变量 [英] How to get variable for a customer from a webhook in WooCommerce

查看:73
本文介绍了如何从 WooCommerce 中的 webhook 获取客户的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WooCommerce 订阅,并为客户取消订阅创建了一个网络钩子...

I am using WooCommerce Subscriptions, and have created a web hook for when a customer cancels their subscription...

我想在发生此事件时将 MySQL 数据库记录从发布"更新为删除".我在交付 URL 中为它创建了一个新页面.

I want to update a MySQL database record from 'Publish' to 'Delete' upon this event occurring. I have created a new page for it etc. in a delivery URL.

FORM/POST PARAMETERS

webhook_id: 4099
HEADERS

Cf-Connecting-Ip: 212.227.29.24
Content-Length: 15
Total-Route-Time: 0
Host: requestb.in
Accept: */*
Cf-Visitor: {"scheme":"https"}
Accept-Encoding: gzip
Referer: https://requestb.in/sqwf1tsq
User-Agent: WooCommerce/3.1.2 Hookshot (WordPress/4.8.1)
Connect-Time: 1
Content-Type: application/x-www-form-urlencoded
Cf-Ray: 39d5a75dc8980f45-FRA
X-Request-Id: e1b16cd7-fb41-471b-9c47-dce0dd7260cc
Cf-Ipcountry: DE
Via: 1.1 vegur
Connection: close
RAW BODY

webhook_id=4099

但是...我如何从网络钩子负载中获取任何变量?它是如此令人困惑(这里是新手!).我想获取为每个用户/客户存储的用户名或名为条形码"的变量,然后我可以在单独的数据库中识别并进行更改.

But... how do I get any variables from a web hook payload? Its so confusing (newbie here!). I'd like to get either the username or a variable called 'barcode' which is stored for each user/customer, which I can then identify in the separate database and make the change.

希望这是有道理的..!

Hope that makes sense..!

将不胜感激,非常感谢!!

Help would be appreciated, Many thanks!!

推荐答案

你响应 webhook 的函数应该监听 php 输入流.

The function you have responding to the webhook should listen for the php input stream.

$input = @file_get_contents("php://input");
var_dump($input); //this will output everything sent to your webhook

从这里,您可以看到您想要获取的属性.

From here, you can see which properties you'll want to grab.

这篇关于如何从 WooCommerce 中的 webhook 获取客户的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆