Cha*_*ona 3 php wordpress woocommerce
我正在开发一个简单的WordPress插件,当管理员将订单标记为"已完成"时,该插件会向表中添加一些信用.我的plugin.php看起来像这样:
<?php 
   function add_credits($order_status, $order_id) {
        global $wpdb, $woocommerce, $current_user;
        $order = new WC_Order($order_id);
        $items = $order->get_items();
         //DO SOME STUFF HERE with items and order
   }//function
   add_action('woocommerce_order_status_completed',   'add_credits');    
Run Code Online (Sandbox Code Playgroud)
但是,当我将订单更改为"COMPLETE"时,此插件不会产生任何结果.我甚至可以在函数的第一行写一个echo或一个简单的指令,并且不运行.
该函数add_credits应该只采用一个参数:
function add_credits($order_id) {
还要确保您的插件在WordPress中激活.
您可以在do_action此处查看包含特定呼叫的源代码:http:
 //docs.woothemes.com/wc-apidocs/source-class-WC_Order.html#_update_status
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           2844 次  |  
        
|   最近记录:  |