I am trying to add a button of “Packing” order inside the order details page. I am doing this via a link that put’s the order from “Processing” to the “Packing” status.
The link requires two things, one is “order” id and other is “nonce” id.
I can get the order id with the following code.

<?php echo $order->id; ?>

But the problem is getting the “nonce” id. Without “nonce” id, the order can’t be able to change its status.

The complete code that I am inserting in the button is:

<a class="button packing" href="http://www.example.com/wp-admin/admin-ajax.php?action=woocommerce_mark_order_status&amp;status=packing&amp;order_id=<?php echo $order->id; ?>&amp;_wpnonce=aba27cf15c"><i class="fa fa-archive" aria-hidden="true"></i></a>

Here in the code, the wpnonce id is static, I want it to be dynamic so that it will change accordingly.[enter image description here][1]

My question is, how can I add the “nonce” id in the button link via PHP code just like I did for the order id?

The button that I am adding on the order page.

Read more here: Trying to add WooCommerce "Packing" button but can’t find the "nonce" id inside the link


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: