![](/img/trans.png)
[英]Wordpress - Woocommerce, Sending SMS through Smsbroadcast API after order has been placed
[英]woocommerce hook when order is placed through REST API
在WooCommerce商店下訂單時,我需要運行一些自定義PHP代碼。 當前,我正在使用woocommerce_order_status_changed
掛鈎,該掛鈎非常適合Web前端。
add_action('woocommerce_order_status_changed', 'order_confirmation',10, 3);
function order_confirmation($order_id,$oldstatus,$newstatus){
//my custom code...
}
但是,通過API下訂單時,不會調用此掛鈎。
通過WooCommerce的Rest Api V2下訂單時,是否可以使用鈎子來執行一些php代碼?
我認為您正在將set_paid屬性發送為true
。 它將狀態設置為“正在處理”並減少庫存項目。 如果您需要在訂單付款完成后執行操作,則可以使用woocommerce_payment_complete操作掛鈎。
function on_woocommerce_payment_complete($order_id){
}
add_action( 'woocommerce_payment_complete', 'on_woocommerce_payment_complete'
);`
但是,只有當訂單狀態來自以下數組時,以上掛鈎才會觸發
on-hold', 'pending', 'failed', 'cancelled
在標記付款完成之前。
對於其他訂購的雕像,將觸發以下掛鈎。
do_action( 'woocommerce_payment_complete_order_status_' . $this->get_status(), $this->get_id() );
有關更多詳細信息,請檢查
public function payment_complete( $transaction_id = '' ) {
定義於
woocommerce\\includes\\class-wc-order.php
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.