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&status=packing&order_id=<?php echo $order->id; ?>&_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]
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?