How to get user nonce for order cancel

Viewed 114

I am trying to implement Woocommerce order cancellation on suborders (for Marketplace model). The problem is, as far as I can see, a URL like this is created in order cancellation: https://www.mywebsite.com/cart.....&_wpnonce=12425

As seen in this URL, there is a nonce at the end. How can I get this dynamically? I searched but couldn't find a solution. According to my research this generates a different code for each user. How can I get this code for current user?

Update: Problem solved. Maybe it helps someone else. Woocommerce uses a scalar value called woocommerce-cancel_order for order cancellation. So in order to get the nonce value in case of cancellation, the code should be as follows:

$nonce_value = wp_create_nonce('woocommerce-cancel_order');
0 Answers
Related