我正在尝试在thankyou.php页面上获取交易ID,但WC_Order对象没有贝宝交易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/

10-11 05:11