2015-06-04 74 views
1

我有一種情況可以在訂單狀態完成按鈕上向數據庫表添加一些數據。 enter image description here在WooCommerce上添加自定義功能完成按鈕

我可以看到網址類-WC-管理-後types.php

enter image description here

有人可以幫助我對任何掛鉤?或者admin-ajax.php如何工作?我必須爲我的一些自定義數據庫表添加狀態。

回答

1

這個代碼將激發客戶的訂單被設置爲已完成..

add_action('woocommerce_order_status_completed', 'custom_task'); 
function custom_task($order_id) { 

    // Only continue if have $order_id 
    if (! $order_id) { 
     return; 
    } 

    // Get order 
    $order = wc_get_order($order_id); 

    // Do your thing 

} 
+0

我自找的管理儀表板內完成按鈕。 –

+1

對不起..比嘗試woocommerce_order_status_completed而不是woocommerce_thankyou – Bart

+0

多數民衆贊成在偉大。有效。請 –

相關問題