php - woocommerce - checkout fails/doesn't work

39

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.

633

Answer

Solution:

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.

857

Answer

Solution:

Someone mentioned that they had this problem when using the GoogleRECAPTCHA plug-in with Woocommerce. They disabled it, and the problem went away. :)

241

Answer

Solution:

@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. :)

843

Answer

Solution:

As an alternate fix, if you are using a self-signed SSL certificate in staging (or if your SSL is expired) and you have elected to force https in the checkout view, it will cause PayPal to fail with this rather unhelpful message.

You'll know you have this problem because WordPress will be constantly logging you out of the admin and forcing you to re-authenticate any time the secure/insecure hand off happens.

People are also looking for solutions to the problem: How to extract classes from SOAP XML via PHP?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.