I've spent all day on this and I've run out of ideas.
https://www.thunderbrook.co.uk
I've taken over dev of an old site that was running woocommerce with a Theme by cardinal. I wasn't comfortable developing using such a intensive theme so I migrated to storefront and started again.
I've kept all the old products, orders etc.
The site was working well, so I made a backup of the database and the actual files on server from my local MAMP environment, uploaded them to wordpress in a zip.
I then moved the old site to a random folder without a name and dropped the database.
I then unzipped the new files into the websites root and imported the database.
I had already changed the config and options file to have the correct site root, logins, etc and it was working fine, EXCEPT... woocommerce can't complete payments. It lets you get all the way to the point of choosing payment and then provides a internal server error.
Console is showing:
POST https://www.thunderbrook.co.uk/checkout/?wc-ajax=checkout 500 (Internal Server Error)send @ jquery.js:5m.extend.ajax @ jquery.js:5b.submit @ checkout.min.js:1m.event.dispatch @ jquery.js:4r.handle @ jquery.js:4
I am at a loss how to proceed, 500 is an incredibly common error and not much other detail has been given.
Deactivating all plugins crashed my host resulting in a long outage. I've since deactivated one by one and retested with no change in behavior..
Anyone know where I should look next?
I did check my log error files and got this:
[09-Jan-2016 15:03:51 UTC] PHP Fatal error: Call to a member function add_product() on a non-object in /home/thunderbrook/public_html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php on line 222
That line of that file hasn't changed since the site was working.
// Store the line items to the new/resumed order foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { $item_id = $order->add_product( $values['data'], $values['quantity'], array( 'variation' => $values['variation'], 'totals' => array( 'subtotal' => $values['line_subtotal'], 'subtotal_tax' => $values['line_subtotal_tax'], 'total' => $values['line_total'], 'tax' => $values['line_tax'], 'tax_data' => $values['line_tax_data'] // Since 2.2 ) ) );
My only guess outside of the jquery version, is that my database of products didn't import properly, so now it can't pull in all the fields it is looking for or something?
I've tried checking out with a variety of products, all the same result.
$order
object is not creating for some reason. an order can be resumed or created new. please debug on these both condition by including your log code. Then after finding you can remove your code.