哪个WooCommerce挂钩或功能通过方坯和信用卡接收付款响应? [英] Which WooCommerce hook or function that receives the payment response by billet and credit card?

查看:46
本文介绍了哪个WooCommerce挂钩或功能通过方坯和信用卡接收付款响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用woocommerce实施集成.在确认方坯或信用卡付款后,我想将用户购买的商品发送到其他系统.有人知道我可以在哪里获得退还的付款以及如何获得购买的交易ID吗?

I am implementing an integration using woocommerce. I would like to send the purchase made by the user to other system after the payment of the billet or credit card is confirmed. Does anyone know where I can get this return of the payment and how do I get the purchase's transaction ID?

我尝试了下面的代码,但似乎未调用该函数;

I tried the code below, but the function doesn't seem to have been called;

add_action( 'woocommerce_payment_complete','send_payed_order_to_omie');
function send_payed_order_to_omie($order_id)
{
  /*Código que envia a venda para o ERP*/
}

推荐答案

这是已付款订单(不包括需要手动完成的"bacs"(银行电汇)和支票"付款)的正确钩子.

您可以在

You can see that in the source code of WC_Order payment_complete() method (used by all payment methods), where woocommerce_payment_complete hook is located, that set the transaction ID (when it's returned by the payment gateway).

要获取交易ID,可以使用 WC_Order get_transaction_id()方法.

To get the transaction ID you can use the WC_Order get_transaction_id() method.

所以您的代码将是:

add_action( 'woocommerce_payment_complete','send_payed_order_to_omie');
function send_payed_order_to_omie( $order_id ) {
    $order = wc_get_order( $order_id );

    $transaction_id = $order->get_transaction_id();

    // Your other code
}

代码进入活动子主题(或活动主题)的functions.php文件中.应该可以.

Code goes in functions.php file of the active child theme (or active theme). It should work.

这篇关于哪个WooCommerce挂钩或功能通过方坯和信用卡接收付款响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆