2

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.

4
  • $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.
    – WPTC-Troop
    Jan 9, 2016 at 16:20
  • I'm not sure I understand your instruction, but I'd appreciate your help. Jan 9, 2016 at 17:44
  • you have to debug... try looking why it's giving fatal error.... Jan 10, 2016 at 0:12
  • Yes totally agreed @markratledge, find and replace option doesn't changes the serialize data. Try using this plugin for DB migration : wordpress.org/plugins/wp-migrate-db It will take care of all the needed changes. Jan 11, 2016 at 6:29

2 Answers 2

1

I had already changed the config and options file to have the correct site root, logins, etc

Did you change all URLs in the database, or just the two site address options in wp_options?

If there are old MAMP URLs in the database, this could be the issue. See WordPress Serialized PHP Search Replace Tool to correctly change URLs in the database. Don't change URLs in a text dump; this will break serialized data.

1
  • +1000 I can't believe how much my life improved when I found this tool. Should come with WordPress. Jan 10, 2016 at 1:00
-1

Try these steps :

  1. take a backup of database.
  2. Open the database(MySQL file) in dreamweaver or any editor.
  3. Find site_url and replace the site_url value with the new siteurl of your domain in the entire MySQL file (find and replace option).
  4. Upload this new replaced MySQL file to the database newly created on server.
  5. Now, take backup of files and upload it as it is to root folder.
  6. Open up the wp-admin and upload the new theme you want to use.
  7. Done !!

Hope this works !!!

Instead of changing the site_url in just 2 places in wp_options its better to find and replace all site_url's

1
  • Never find/replace URLs in a text dump; this breaks serialzed data. Jan 9, 2016 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.