【发布时间】:2016-05-25 00:57:53
【问题描述】:
我在 Wordpress 的 Storefront 子主题的 functions.php 文件中使用此代码。
<?php
function action_woocommerce_api_create_order( $order_id, $data, $instance ) {
include get_stylesheet_directory().'/agilephpcode/CurlLib/curlwrap_v2.php';
$event_json = array(
"start"=>1455256687,
"end"=>1455246687,
"title"=>"this is a test event",
"contacts"=>array(5631986051842048),
"allDay"=>false
);
$event_json = json_encode($event_json);
curl_wrap("events", $event_json, "POST", "application/json");
}
add_action( 'woocommerce_api_create_order', 'action_woocommerce_api_create_order');
?>
我已经在单个 php 页面上测试了从 Include 到 curl_wrap 末尾的代码,它在 Agile CMS 中创建了一个事件。该活动就像聚会或会议,而不是编码活动:)
无论如何,它不会创建事件,我已经尝试了大约四个小时才能让它工作。我在这里缺少什么重要的东西吗?我只是想打电话。我意识到通过创建订单(在他们付款之后)进行派对活动或其他东西是不合逻辑的。
【问题讨论】:
-
糟糕,将 include 放入函数中。现在它在函数调用之上,但仍然不起作用。
-
我只需要将操作更改为“woocommerce_new_order”,现在它似乎工作得很好。这是代码:
标签: woocommerce webhooks