• I am trying simulate Place Order actions from my theme function. I am calling an ajax request from my custom function https://localhost/wp_test/checkout/?wc-ajax=checkout and pass required parameters to it. I am updating my cart by hoking another action to ‘woocommerce_before_checkout_process’.

    I am getting ‘We were unable to process your order, please try again.’. This is because I am not able to pass ‘_wpnonce’ field to this request. If I comment out this check in process_checkout function. I am able to simulate this action correctly.

    Please, let me know how can I simulate this action without hacking core files.

    Thanks and regards

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You need to find out how WC creates the nonce for the same form, then create a hidden field named _wpnonce that has the nonce value you created by the same means. For example, let’s say WC does $nonce = wp_create_nonce( 'wc_checkout_form' );

    I don’t know what WC actually does, this is just an example. Use the same function and parameter that WC uses for its form on your form. If you have trouble locating the proper code, I suggest you ask in the WC dedicated forum where those more familiar with WC code can help you.

Viewing 1 replies (of 1 total)
  • The topic ‘_wpnonce on woocommerce checkout form’ is closed to new replies.