Fatal error on subscription renewal
-
Hello
really many thanks for this amazing plugin. I love it.
Be careful, the function wcs_renewal_order_created() may trigger a fatal error in some rare situations.
In
On line 1262 you have:
$vat_number = trim($renewal_order->get_meta('vat_number'));
$renewal_order is most of the time an object, but not always. I think you should check if it’s an object before calling the method get_meta().
In my specific case, the fatal error is triggered when I manually trigger a subscription renewal of the plugin WooCommerce Subscriptions. In my case, $renewal_order is a boolean variable when your function is called.
I have some other plugins, and I haven’t investigated the issue deeper. Probably one of the other plugins conflicts with yours. In any case, I think it’s easier to check that $renewal_order is an object and that’s it. And you avoid any kind of issues when you call the method.
In my case I’ve added this line of code before line 1262:
if( !is_object( $renewal_order ) || !method_exists( $renewal_order,'get_meta' ) ) return $renewal_order;
But of course, when next time I update your plugin I will lose it, so it would be great if you can fix it in your code if for you it’s not a problem.
Thank you very much in advance.
- The topic ‘Fatal error on subscription renewal’ is closed to new replies.