简体   繁体   English

在 WooCommerce “收到订单”谢谢页面上获取订单 ID

[英]Get the order id on WooCommerce “Order received” Thankyou page

I will customize the thankyou page from my WoocCommerce shop.我将从我的 WoocCommerce 商店自定义感谢页面。 For this I added a blanc thankyou.php into the WooCommerce checkout directory.为此,我在 WooCommerce 结帐目录中添加了一个 blancthankyou.php。

I tried this code我试过这段代码

function get_order($order_id) {
    echo $order_id;
}
add_action('woocommerce_thankyou', 'get_order');

But the variable $order_id is empty.但是变量 $order_id 是空的。

Is there somebody who knows how I get the order id on the thankyou page?有人知道我如何在谢谢页面上获得订单 ID 吗?

If Url is like www.example.com/checkout/order-received/1234/?key=wc_order_s5ou6md6nTZDds you can use the following to get the order id:如果 Url 类似于www.example.com/checkout/order-received/1234/?key=wc_order_s5ou6md6nTZDds您可以使用以下命令获取订单 ID:

global $wp;

if ( isset($wp->query_vars['order-received']) ) {
    $order_id = absint($wp->query_vars['order-received']); // The order ID
    $order    = wc_get_order( $order_id ); // The WC_Order object
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WooCommerce-在“谢谢”订单接收页面上自定义“总计”文本 - WooCommerce - Customize “Total” text on Thankyou order received page 在“收到的WooCommerce订单(谢谢)”页面中检查新客户 - Check for new customers in WooCommerce Order received (Thankyou) page 在Woocommerce订单接收页面中以简码获取订单ID - Get the Order ID in Woocommerce order received page as shortcode 根据订单状态更改 WooCommerce 感谢页面标题 - Change WooCommerce thankyou page title based on order status 在收到的Woocommerce订单中的javascript中设置订单ID和订单总数 - Set order id and order total in a javascript on Woocommerce order received 发送订单确认 email 通知 WooCommerce 谢谢 - Send Order Confirmation email notification in WooCommerce thankyou Woocommerce:订单ID中的产品ID - Woocommerce: product id in the order received url 按照从 woocommerce 收到的页面的顺序更改文本 - Change text in order received page from woocommerce WooCommerce 将“收到订单”页面重定向到 ACF URL - WooCommerce redirect 'order received' page to ACF URL 显示自定义动态字段存储数据 woocommerce 订单管理和来自元的感谢页面。? - Display custom dynamic fields stored data woocommerce order admin and thankyou page from meta.?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM