php - 如何在 WooCommerce 中获取 Paypal 交易 ID?

标签 php wordpress paypal woocommerce

我正在尝试获取 thankyou.php 页面上的交易 ID,但 WC_Order 对象没有 Paypal 交易 ID。

WC_Order 对象:-

WC_Order Object
(
    [order_type] => simple
    [id] => 49
    [post] => WP_Post Object
        (
            [ID] => 49
            [post_author] => 1
            [post_date] => 2016-01-08 13:55:24
            [post_date_gmt] => 2016-01-08 13:55:24
            [post_content] => 
            [post_title] => Order – January 8, 2016 @ 01:55 PM
            [post_excerpt] => 
            [post_status] => wc-pending
            [comment_status] => open
            [ping_status] => closed
            [post_password] => order_568fbfcc2b0f2
            [post_name] => order-jan-08-2016-0155-pm
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2016-01-08 13:55:24
            [post_modified_gmt] => 2016-01-08 13:55:24
            [post_content_filtered] => 
            [post_parent] => 0
            [guid] => http://localhost/lfdemo/?post_type=shop_order&p=49
            [menu_order] => 0
            [post_type] => shop_order
            [post_mime_type] => 
            [comment_count] => 0
            [filter] => raw
        )

    [order_date] => 2016-01-08 13:55:24
    [modified_date] => 2016-01-08 13:55:24
    [customer_message] => 
    [customer_note] => 
    [post_status] => wc-pending
    [prices_include_tax] => 
    [tax_display_cart] => excl
    [display_totals_ex_tax] => 1
    [display_cart_ex_tax] => 1
    [formatted_billing_address:protected] => 
    [formatted_shipping_address:protected] => 
)

我需要一些帮助!所以请发表评论并提供解决方案!

最佳答案

交易 ID 是帖子元数据的一部分...

$transaction_id = get_post_meta($order_id, '_transaction_id', true);

关于php - 如何在 WooCommerce 中获取 Paypal 交易 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34679711/

相关文章:

javascript - 如何在不重新加载页面的情况下填充div

php - 如何在不完全下载的情况下从mysql数据库逐步播放HTML5视频

javascript - 每次在 Safari 和移动浏览器上询问地理位置权限

authentication - PayPal - 需要 Payments Pro 来测试 Mass Pay?

php - 即使付款已发送,PayPal IPN 仍返回 INVALID

php - 从php中的ttf-font获取单个字符的宽度?

PHP 使用系统调用为脚本设置超时,set_time_limit 不起作用

mysql - WordPress插件劫持数据库,如何清理?

javascript - Wordpress AJAX 不起作用 - 响应 0

asp.net - 如何在 Windows Server 2008 R2 上安装 PayPal API 证书