Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 成功付款后,Woocommerce中会触发什么挂钩_Php_Wordpress_Woocommerce_Payment_Hook Woocommerce - Fatal编程技术网

Php 成功付款后,Woocommerce中会触发什么挂钩

Php 成功付款后,Woocommerce中会触发什么挂钩,php,wordpress,woocommerce,payment,hook-woocommerce,Php,Wordpress,Woocommerce,Payment,Hook Woocommerce,在Woocommerce中,要向客户发送短信支付信息,我需要在成功支付后激活触发器 但我没有找到任何钩子做这件事 这是我的插件代码: if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) { add_action( '####Action to be used here#######', array( &$this, 'successful_payment_notific

在Woocommerce中,要向客户发送短信支付信息,我需要在成功支付后激活触发器

但我没有找到任何钩子做这件事

这是我的插件代码:

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();
}
所需的钩子应该出现在代码的第二行


任何帮助都将不胜感激。

您应该尝试使用
woocommerce\u payment\u complete
操作挂钩,它是专门为此而设计的,位于。它在成功付款后触发JU。因此,请尝试:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( 'woocommerce_payment_complete', array( &$this, 'successful_payment_notification_client' ) );
}
您还应该尝试将
数组(&$this,
替换为
数组($this,

或者使用
woocmerce\u payment\u complete\u order\u status\u 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' ) );
}
您还应该尝试将
数组(&$this,
替换为
数组($this,

或者使用
woocmerce\u order\u status\u processing
hook(但有两个参数:
$order\u id
$order
):

您还应该尝试将
数组(&$this,
替换为
数组($this,

代码进入你的插件文件


如果没有构造函数(如类)或没有实例化对象,则应按以下方式使用
add()
action函数:

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

您应该尝试使用专门为此而设计并位于中的
woocommerce\u payment\u complete
操作挂钩。它在成功付款后被触发。因此,请尝试:

if ( isset( $this->options['wc_notify_customer_payment_successful_enable'] ) ) {
    add_action( 'woocommerce_payment_complete', array( &$this, 'successful_payment_notification_client' ) );
}
您还应该尝试将
数组(&$this,
替换为
数组($this,

或者使用
woocmerce\u payment\u complete\u order\u status\u 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' ) );
}
您还应该尝试将
数组(&$this,
替换为
数组($this,

或者使用
woocmerce\u order\u status\u processing
hook(但有两个参数:
$order\u id
$order
):

您还应该尝试将
数组(&$this,
替换为
数组($this,

代码进入你的插件文件


如果没有构造函数(如类)或没有实例化对象,则应按以下方式使用
add()
action函数:

 add_action( 'the_hook', 'the_hooked_function', $priority, $nb_of_args );
使用“woocommerce\u payment\u complete”挂钩


使用“woocommerce\u payment\u complete”钩子

您好tnx我尝试了这个(woocommerce\u payment\u complete),但没有回答。例如,尝试这个(woocommerce\u new\u order)并在购买前发送消息,我确保代码正常工作。我可以将其连接到将订单信息发送到电子邮件的操作吗?因为电子邮件是在付款完成后发送的。谢谢。付款成功后,它会更改(正在进行)。:-)是,“正在处理”上述项目不起作用……一位朋友告诉我,他有三种方法……1-给钩子2-cron作业最后一个优先级3-把钩子放在wp钩子中。(add_action('wp',…)……你的看法是什么?你在问题中没有告诉我它真正的用途。1)在插件或类中,使用
add_action的构造函数('thew_hook',array('this'thew_hooked_function'))
…2)如果没有构造函数(或类或实例化对象),则使用
add_操作('thew_hook','thew_hooked_function'))
…现在缺少了一些东西,如挂接函数的优先级和参数数量。因此,您应该尝试各种可能性,因为您并不真正知道自己在做什么。您好tnx我尝试了这个(woocommerce\u payment\u complete),但没有回答。例如,尝试这个(woocommerce\u new\u order)并在购买前发送消息,我确保代码正常工作。我可以将其连接到将订单信息发送到电子邮件的操作吗?因为电子邮件是在付款完成后发送的。谢谢。付款成功后,它会更改(正在进行)。:-)是,“正在处理”上述项目不起作用……一位朋友告诉我,他有三种方法……1-给钩子2-cron作业最后一个优先级3-把钩子放在wp钩子中。(add_action('wp',…)……你的看法是什么?你在问题中没有告诉我它真正的用途。1)在插件或类中,使用
add_action的构造函数('thew_hook',array('this'thew_hooked_function'))
…2)如果没有构造函数(或类或实例化对象),则使用
add_操作('thew_hook','thew_hooked_function'))
…现在缺少了一些东西,如挂接函数的优先级和参数数量。因此,您应该尝试各种可能性,因为您并不真正知道自己在做什么。