Woocommerce:在结帐页面后获取订单ID [英] Woocommerce: Get order id after checkout page

查看:152
本文介绍了Woocommerce:在结帐页面后获取订单ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经购买了Woocommerce订阅插件,我希望能够在结帐页面中获得订单ID。
我想要这个,因为当订阅即将结束时,带有付款链接的电子邮件将发送给客户,并自动添加订单。当客户单击链接时,它将重定向到结帐页面以支付订单费用。
我需要订单ID才能使用某些函数(如wc_get_order_item_meta())从特定订单中检索元数据。

I have purchased the Woocommerce Subscriptions plugin and i want to be able to get the order ID in checkout page. I want this, because when a subscription is about to end, an email with a payment link is sent to the customer and an order is automatically added. When customer clicks the link, it redirects to the checkout page in order to pay for the order. I need the order ID to retrieve meta data from the specific order using some function like wc_get_order_item_meta().

推荐答案

您可以这样获得:

    global $wp;
    $order_id = $wp->query_vars['order-pay'];
    $order = new WC_Order( $order_id );

这篇关于Woocommerce:在结帐页面后获取订单ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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