我正在开发用于从谷歌分析帐户获取额外数据的模块。为了获得这些数据,谷歌需要 access_token。这是我到目前为止所管理的
if (isset($_GET['code'])) {
// try to get an access token
$code = $_GET['code'];
$url = 'https://accounts.google.com/o/oauth2/token';
$params = array(
"code" => $code,
"client_id" => "559825975819-881lg83vs8feo70v5unqa8kfoijuvfnn.apps.googleusercontent.com",
"client_secret" => "vj4UNNItAJocX4RkNaD_3DQ4",
"redirect_uri" => 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["PHP_SELF"],
"access_type" => "offline",
"grant_type" => "authorization_code"
);
$ch = curl_init();
curl_setopt($ch, constant("CURLOPT_" . 'URL'), $url);
curl_setopt($ch, constant("CURLOPT_" . 'POST'), true);
curl_setopt($ch, constant("CURLOPT_" . 'POSTFIELDS'), $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$data = (json_decode($output, true));
$access_token_var = $data['access_token'];
echo …Run Code Online (Sandbox Code Playgroud) 如何编辑 admin-new-order.php WooCommerce 模板以根据运输方式有条件地发送一些自定义客户详细信息?
例如(对于新订单电子邮件通知):
flat rate,我想在客户详细信息中添加一些自定义字段信息。flat rate,我不希望显示自定义字段信息。或者也许 function.php 中有一些片段可以用于此目的?