woocommerce - checkout fails/doesn't work
Solution 1
I got the solution. With the WooCommerce 2.3.5 update, two new files got added: payment.php & payment-method.php. In payment.php there's this line:
<?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>
Somehow this line got removed in my child theme.
Solution 2
Someone mentioned that they had this problem when using the GoogleRECAPTCHA plug-in with Woocommerce. They disabled it, and the problem went away. :)
Solution 3
@SPS if you really are on woocommerce 2.3.5, there should be the file payment.php wp-content/plugins/woocommerce/templates/checkout/
Meanwhile, that's not the actual culprit in my own case; (as there was already
<?php wp_nonce_field( 'woocommerce-process_checkout' ); ?>
there ) It's rather the fact that inside, the process_payment(){} function of my payment plugin, i was returning:
array
(
'result' => 'success',
'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id'))))
);
instead of
array
(
'result' => 'success',
'redirect' => add_query_arg('order',$order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay' ))))
);
Check your code to change that too, and the problem will dissapear. :)
Luc
Updated on June 29, 2022Comments
-
Luc almost 2 years
My woocommerce checkout is showing and up till this morning was working fine. But now when I try to submit the form I get this message: "We were unable to process your order, please try again". I haven't changed anything in the settings or plugins. I have updated woocommerce recently to 2.3.5. But still, everything worked perfectly after that. I really don't get what's going on here. I hope someone can help me out.
Thanks!
PS: I get this error message with everything, even when I leave a billing field open...
_____ EDIT ______
I found the function which throws the error:
if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-process_checkout' ) ) { WC()->session->set( 'refresh_totals', true ); throw new Exception( __( 'We were unable to process your order, please try again.', 'woocommerce' ) ); }
This is located in in woocommerce/includes/class-wc-checkout.php on line 351.
-
SPS about 9 yearsHey! I'm running into the same problem, but I don't have a payment.php in my child theme. Can you explain how you resolved this issue?
-
DeLac over 7 yearsactually I have this problem.... I am constantly logged out and the check-out doesn't work. I've just added an SSL installed by my host service. Anyway, I have the same problem even if I don't check the "force SSL" flag