• We have a custom email that does not pass an Order object, however the code in woocommerce-pdf-invoice.php doesn’t check for a WC_Order type before calling get_id()

    This results in a fatal error:

    PHP Fatal error: Uncaught Error: Call to undefined method stdClass::get_id() in /Users/torre/Documents/wwwroot/wp-content/plugins/woo-pdf-invoice-builder/woocommerce-pdf-invoice.php:246

    Can you add a check for the type of WC_Order object? For example, changing line 232 would do the trick:
    if ( !is_object( $order ) || !isset( $email_id ) || !is_a( $order, 'WC_Order' ) ) {

    Alternatively, check for the method before calling it:
    if ( !is_object( $order ) || !isset( $email_id ) || !method_exists( $order, 'get_id' ) ) {

    Let me know if you need any other details, thanks!

The topic ‘Fatal error’ is closed to new replies.