久久久久久久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)
主站蜘蛛池模板: 久久国产精品免费一区二区三区 | 久久精品一级 | 欧美mv日韩mv国产网站91进入 | 91免费高清视频 | 成人免费视频 | 午夜免费福利片 | 欧美日韩激情 | 免费在线成人 | 欧美6一10sex性hd | 亚洲三区在线观看 | 九九av| 精品久久久久久久人人人人传媒 | 欧美成人一区二区 | 久久精品久久久久久 | av片在线观看 | 欧美日韩成人在线 | 亚洲一区二区三区桃乃木香奈 | 成人免费淫片aa视频免费 | 九九伊人sl水蜜桃色推荐 | 精品一区二区三区在线观看国产 | 欧美日在线| 别c我啊嗯国产av一毛片 | 在线观看www视频 | 国产91综合 | 国产精品视频久久 | 在线成人免费av | 久在线视频播放免费视频 | 男人的天堂在线视频 | 99精品一区二区三区 | 亚洲性人人天天夜夜摸 | 男人的天堂久久 | 日韩激情一区 | 精品伊人 | 91亚洲国产成人久久精品网站 | av一级久久 | 国产精品视频入口 | 亚洲精品永久免费 | 91黄在线观看 | 欧美日韩一区二区在线观看 | 超碰地址 | 日本国产精品视频 |