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
Wordpress $order get事务id为空_Wordpress_Woocommerce_Hook Woocommerce - Fatal编程技术网

Wordpress $order get事务id为空

Wordpress $order get事务id为空,wordpress,woocommerce,hook-woocommerce,Wordpress,Woocommerce,Hook Woocommerce,嗨,我目前正在为woo commerce支付网关开发一个插件 我需要帮助访问“处理付款”功能上的交易id 基于文档,使用此代码获取事务id public function process_payment( $order_id ) { global $woocommerce; $order = wc_get_order( $order_id ); $transaction_id = $order->get_transaction_id() //do stuff }

嗨,我目前正在为woo commerce支付网关开发一个插件

我需要帮助访问“处理付款”功能上的交易id

基于文档,使用此代码获取事务id

public function process_payment( $order_id ) {
  global $woocommerce;
  $order = wc_get_order( $order_id );     
  $transaction_id = $order->get_transaction_id()

//do stuff
}
但是$transaction\u id的结果为空。但是,当我尝试访问诸如$order->get_total()和get_payment()之类的内容时,这种方法是可行的

我试图从元数据获取它,但在事务id上也返回空

$transaction\u id=get\u post\u meta($order\u id,'u transaction\u id',true)

知道如何获取交易id吗

订单对象:

{“id”:76,
”parent_id”:0,
”status”:”processing”,
”currency”:”EUR”,
”version”:”4.0.1″,
”prices_include_tax”:false,
”date_created”:{“date”:”2020-04-23 12:17:27.000000″,”timezone_type”:3,
”timezone”:”Europe/Berlin”},
”date_modified”:{“date”:”2020-04-23 12:17:27.000000″,”timezone_type”:3,
”timezone”:”Europe/Berlin”},
”discount_total”:”0″,
”discount_tax”:”0″,
”shipping_total”:”3.99″,
”shipping_tax”:”0″,
”cart_tax”:”0″,
”total”:”22.99″,
”total_tax”:”0″,”customer_id”:2,
”order_key”:”wc_order_0SBeR4y6o7CqX”,
”billing”:{“first_name”:”Mustain123″ ”last_name”:”Billah”,
”company”:””,
”address_1″:”Alfred-Messel-Weg 8″,
”address_2″:””,
”city”:”Darmstadt”,
”state”:””,”postcode”:”64287″,”country”:”DE”,
”email”:”mustain.bilah.4@gmail.com”,
”phone”:”+4915774087126″},”
shipping”:{“first_name”:”Mustain 123″,
”last_name”:”Billah”,
”company”:””,
”address_1″:”Alfred-Messel-Weg 8″,
”address_2″:””,
”city”:”Darmstadt”,
”state”:””,
”postcode”:”64287″,”country”:”DE”},
”payment_method”:”cryptopay”,”
payment_method_title”:”CryptoPay”,
”transaction_id”:””,
”customer_ip_address”:”::1″,”customer_user_agent”:”Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0″,”created_via”:”checkout”,”customer_note”:””,”date_completed”:null,”date_paid”:{“date”:”2020-04-23 12:17:27.000000″,”timezone_type”:3,”timezone”:”Europe/Berlin”},”cart_hash”:”49f0749ac4376e4be250c1b86e4b75d0″,”number”:”76″,”meta_data”:[{“id”:2512,”key”:”is_vat_exempt”,”value”:”no”}],”line_items”:{“287″:{}},”tax_lines”:[],”shipping_lines”:{“288″:{}},”fee_lines”:[],”coupon_lines”:[]}```