从functions.php获取自定义参数

问题描述:

要点是: wordpress向'personX'发送'订单已收到'邮件,邮件中包含一个链接(应该将订单状态设置为'已完成')我把将订单,所以我可以检索和使用此代码更改订单状态:从functions.php获取自定义参数

//-> insert code that last few characters of URL and put that in $order_id 

    // Get order 
     $order = wc_get_order($order_id); 

    // Update order to completed status 
     $order->update_status('completed'); 

当我点击了链接,personX收到的邮件(接收邮件默认woocommerce订单+我的自定义链接,自定义页面:https://snag.gy/Nyhkcu.jpg)并回显页面的当前URL,它不会回显query_string(后面的部分?)。

我建的URL字符串是这样的:

<a href="'. admin_url('/orderConfirmationPage/?orderId=' . absint($order->id) ) .'" > 

反正呼应订单ID的网页? (这样我就可以尝试从第一个代码块中测试代码)

+1

echo $ _GET ['orderId']; http://php.net/manual/en/reserved.variables.get.php – Kaylined

+0

真棒!这样可行!非常感谢 ! – robertjuh

你的字符串在回声标签&管理URL也是不妥当 变化打破它喜欢下面

$added_string = "?orderId=".$order->id; 
 
$admin_url = get_permalink(get_page_by_title('orderConfirmationPage')); 
 
echo '<a href="'.admin_url($admin_url).''.$added_string'" ></a>';

+0

嘿,谢谢你的回答,我试了一下,但是它把我带到了/wp-admin/www.mysite.nl/orderconfirmationpage。所以没有工作:/ 改变它到这个(和作品): \t $ added_string =“?orderId =”。$ order-> id; \t $ admin_url = get_permalink(get_page_by_title('orderconfirmationpage')); \t $ link3。=''; 但仍不能将订单ID回显到它重定向到的页面。 – robertjuh

+0

$ actual_link =“http:// $ _ SERVER [HTTP_HOST] $ _SERVER [REQUEST_URI]”; \t \t \t \t var_dump($ actual_link); – robertjuh

+0

我会更新问题 – robertjuh