• Resolved websnacks

    (@websnacks)


    Hi there,

    We just upgraded to WooCommerce 2.5 and we got an error when adding products to a new order in the admin part.

    <b>Fatal error</b>: Call to a member function get_attributes() on a non-object in <b>/path/website/wp-content/plugins/woocommerce/includes/class-wc-product-variation.php</b> on line <b>664

    I fixed the problem by changing the code on line 664 from:

    $attributes = $this->parent->get_attributes();

    into:

    $attributes = $this->get_attributes();

    I am not sure what caused the problem sinds some products could be found, but some couldn’t. So I think it has something to do with the way products are set up. Let me know if you need more information.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    Sounds like the variation you’re adding has no parent?

    Hi! I’ve recently run into the same issue on a couple of websites.

    For some reason, WooCommerce will sometimes leave orphaned variations in the database after deleting the parent product. This really should not happen and is for the moment unclear what causes it to happen.

    This causes lots of issues in the admin side, like not being able to add products to Coupons, or not being able to add products to orders; both due to PHP Fatal errors like you mentioned.

    I’ve created a tool which will let you delete all of the orphaned variation products from the database. They really shouldn’t exist. Have a go:

    https://github.com/anttiviljami/woocommerce-clean-orphaned-variations

    Mark Ward

    (@markwarddesign)

    @anttiviljami your plugin works as expected. Thanks!

    @anttiviljami You sir, are a legend!!!

    Amazing simple solution! Thank you so much @anttiviljami! I’ve spent hours trying to figure out what was causing that annoying issue. WooCommerce should fix this asap!

    @anttiviljami Your plugin have fixed it! Thank you a million times!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘get_formatted_variation_attributes() function error when adding products [fixed]’ is closed to new replies.