2016-11-18 14 views
-1

Wordpress Woocommerceをコード化しようとしているため、すべての新規注文は注文ステータスによって「完了」とマークされています。コードが機能していません。私は間違って何をしていますか?Woocommerceのデフォルト注文ステータス

私はのfunctions.phpにこれを追加しました:

function autocomplete_orders() { 
    add_action('woocommerce_thankyou', 'autocomplete_all_orders'); 
    /** 
    * sp_autocomplete_all_orders 
    * 
    * Register custom tabs Post Type 
    * 
    * @param int $order_id 
    * 
    * @return null 
    */ 
    function autocomplete_all_orders($order_id) { 
     global $woocommerce; 

     if (!$order_id) 
      return; 
     $order = new WC_Order($order_id); 
     $order->update_status('completed'); 
    } 
} 
+0

は、関数 'autocomplete_orders'を削除し、あなたの' functions.php' –

+0

あなたが呼び出すためのアクションを追加する必要があります 'でそれにコードを残しますautocomplete_orders() '、明らかにこれは当てはまりません。 woocommerce_thankyouアクションはそれなしでは決して発動しません。 – Benoti

+0

http://stackoverflow.com/questions/35686707/woocommerce-auto-complete-paid-orders-depending-on-payment-methods/35689563#35689563 – LoicTheAztec

答えて

2
add_action('woocommerce_thankyou', 'autocomplete_all_orders'); 
function autocomplete_all_orders($order_id) { 

    if (! $order_id) { 
     return; 
    } 

    $order = wc_get_order($order_id); 
    $order->update_status('completed'); 
} 
関連する問題