久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

支付成功后,Woocommerce中觸發What hook

After a successful payment, What hook is triggered in Woocommerce(支付成功后,Woocommerce中觸發What hook)
本文介紹了支付成功后,Woocommerce中觸發What hook的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在 Woocommerce 中,要向客戶發送短信付款信息,我需要在成功付款后激活觸發器.

但是我沒有找到任何鉤子來做

這是我的插件代碼:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {add_action( '####Action 在這里使用#######', array( &$this, 'successful_payment_notification_client' ) );}/* WooCommerce 支付成功通知客戶端** @param $order_id*/公共函數 success_payment_notification_client ( $order_id ) {//檢查移動字段是否為空如果(空($_REQUEST['mobile'])){返回;}$order = new WC_Order( $order_id );$this->sms->to = array( $_REQUEST['mobile'] );$template_vars = 數組('%order_id%' =>$order_id,'%order_number%' =>$order->get_order_number(),'%status%' =>$order->get_status(),'%billing_first_name%' =>$_REQUEST['billing_first_name'],'%billing_last_name%' =>$_REQUEST['billing_last_name'],'%transaction_id%' =>get_post_meta( $order_id,'_payment_method_title', true ),);$message = str_replace( array_keys( $template_vars ), array_values( $template_vars ), $this->options['wc_notify_customer_payment_successful_message'] );$this->sms->msg = $message;$this->sms->SendSMS();}

所需的鉤子應該出現在我的代碼的第二行.

任何幫助將不勝感激.

解決方案

你應該嘗試使用 woocommerce_payment_complete 動作鉤子,它是專門為此制作的,位于 woocommerce_payment_completea rel="nofollow noreferrer">WC_Order payment_completed() 方法.它在成功付款后立即觸發.所以試試:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {add_action( 'woocommerce_payment_complete', array( &$this, 'successful_payment_notification_client' ) );}

<塊引用>

您還應該嘗試將 array( &$this, 替換為 array( $this, .

或者使用woocommerce_payment_complete_order_status_processing鉤子:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {add_action('woocommerce_payment_complete_order_status_processing', array( &$this, 'successful_payment_notification_client' ) );}

<塊引用>

您還應該嘗試將 array( &$this, 替換為 array( $this, .

或使用 woocommerce_order_status_processing 鉤子 (但有 2 個參數:$order_id$order):>

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {add_action( 'woocommerce_order_status_processing', array( &$this, 'successful_payment_notification_client' ) );}

<塊引用>

您還應該嘗試將 array( &$this, 替換為 array( $this, .

代碼進入你的插件文件......


<塊引用>

如果沒有構造函數(比如一個類)或沒有實例化對象,你應該這樣使用 add() 動作函數:

 add_action( 'the_hook', 'the_hooked_function', $priority, $nb_of_args );

In Woocommerce, to send sms payment information to the customer, I need to activate a trigger after a successful payment.

But I didn't find any hook do it

This is my plugin code:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( '####Action to be used here#######', array( &$this, 'successful_payment_notification_client' ) );
}

/* WooCommerce Successful payment notification client 
 *
 * @param $order_id
 */
public function successful_payment_notification_client ( $order_id ) {
    // Check the mobile field is empty
    if ( empty( $_REQUEST['mobile'] ) ) {
        return;
    }
    $order          = new WC_Order( $order_id );
    $this->sms->to  = array( $_REQUEST['mobile'] );
    $template_vars  = array(
        '%order_id%'           => $order_id,
        '%order_number%'       => $order->get_order_number(),
        '%status%'             => $order->get_status(),
        '%billing_first_name%' => $_REQUEST['billing_first_name'],
        '%billing_last_name%'  => $_REQUEST['billing_last_name'],
        '%transaction_id%'     => get_post_meta( $order_id,'_payment_method_title', true ),
    );
    $message        = str_replace( array_keys( $template_vars ), array_values( $template_vars ), $this->options['wc_notify_customer_payment_successful_message'] );
    $this->sms->msg = $message;
    $this->sms->SendSMS();
}

The desired hook should come in line two of my code.

Any help will be appreciated.

解決方案

You should try to use woocommerce_payment_complete action hook that is just made specifically for that and located in WC_Order payment_completed() method. It's triggered jus after a successful payment. So try:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( 'woocommerce_payment_complete', array( &$this, 'successful_payment_notification_client' ) );
}

You should try also to replace array( &$this, by array( $this, instead.

Or using woocommerce_payment_complete_order_status_processing hook:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( 'woocommerce_payment_complete_order_status_processing', array( &$this, 'successful_payment_notification_client' ) );
}

You should try also to replace array( &$this, by array( $this, instead.

or using woocommerce_order_status_processing hook (but with 2 arguments: $order_id and $order):

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( 'woocommerce_order_status_processing', array( &$this, 'successful_payment_notification_client' ) );
}

You should try also to replace array( &$this, by array( $this, instead.

Code goes in your plugin file…


If there is no constructor (like for a class) or no instantiated object, you should use add() action function this way:

 add_action( 'the_hook', 'the_hooked_function', $priority, $nb_of_args );

這篇關于支付成功后,Woocommerce中觸發What hook的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 亚洲免费视频网站 | 在线视频一区二区三区 | 欧美视频 亚洲视频 | 久久在线 | 久久这里有精品 | 色性av | 免费看黄色视屏 | 欧美日韩在线一区 | 国产精品久久久久久久久久免费看 | 久久精品无码一区二区三区 | 久久久久99 | yiren22综合网成人 | 亚洲精品国产精品国自产在线 | 国产精品成av人在线视午夜片 | 亚洲精品免费视频 | 日韩欧美专区 | 午夜免费在线电影 | 成人av片在线观看 | 五月综合激情在线 | 99久久久国产精品免费消防器 | 99久久国产精 | 欧美精品1区2区 | 91青青草视频 | 一区二区三区在线播放 | 国产高清自拍视频在线观看 | 日韩成人专区 | 手机看黄av免费网址 | 欧美一级毛片在线播放 | 中文在线一区二区 | 亚洲精品一区二区在线观看 | 精品一区在线免费观看 | 一区二区三区在线播放 | 另类一区 | 欧美日韩在线免费观看 | 女同av亚洲女人天堂 | 一区二区三区视频在线免费观看 | 91看片在线 | 免费久久久久久 | 精品国产乱码久久久久久88av | 毛片视频免费观看 | 成人毛片视频免费 |