Woocommerce PHP Webhook不工作

问题描述:

我在Wordpress中的Storefront子主题的myfunction.php文件中使用此代码。Woocommerce PHP Webhook不工作

<?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页面上的curl_wrap的结束,它会在敏捷CMS的事件。该事件将像聚会或会议,而不是编码事件:)

无论如何,它不创建事件,我已经尝试了大约四个小时才能使其工作。有什么我在这里失踪的大事吗?我只是想打电话。我意识到举办派对活动或创建订单(在他们付款后)是不合逻辑的。

+0

哎呀,把包括函数内。现在它在函数调用之上,但仍然不起作用。 – docaberle

+0

我只需将操作更改为“woocommerce_new_order”,现在看起来工作得很好。代码如下: – docaberle

<?php 
include get_stylesheet_directory().'/agilephpcode/CurlLib/curlwrap_v2.php'; 
function action_woocommerce_api_create_order($order_id, $data, $instance) { 
    $event_json = array(
     "start"=>1455256687, 
     "end"=>1455246687, 
     "title"=>"this is a test event4", 
     "contacts"=>array(5631986051842048), 
     "allDay"=>false 
    ); 

    $event_json = json_encode($event_json); 
    curl_wrap("events", $event_json, "POST", "application/json"); 
} 

add_action('woocommerce_new_order', 'action_woocommerce_api_create_order'); 

?>