Compatibility issue with WooCommerce 5.0.0 and Compatibility mode
-
Hi,
When enabling the 404page compatibility mode on a clean WooCommerce installation and an order programatically goes from “Pending” to “Processing” (read: some piece of code uses
WC_Order->payment_complete()
) then the fatal error shown below appears.So; how to test:
- Create fresh installation and install 404page and WooCommerce (latest 5.0.0)
- Create a new order and set it to “Pending” in the UI
- Either find a payment gateway that will run WC_Order->payment_complete() or use the code snippet below
Why is it 404page?
The short answer is that the error stops occurring when 404page is disabled and I’ve specifically narrowed it down to
add_filter( 'the_posts', array( $this, 'show404_compatiblity_mode' ), 999 );
in theclass-404page.php
file. Removing this filter will make the WooCommerce email during payment complete retrieve posts.How to reproduce example
add_action( 'init', function () { // add "?test=test" to the URL to avoid this being run on all requests. Or just remove it completely. It's up to you! if ( ! isset( $_GET['test'] ) ) { return; } // Change 123 to your orders ID. $order = wc_get_order(123); $order->payment_complete(); } );
Error message
#0 /var/www/html/wp-content/plugins/woocommerce/templates/emails/email-order-items.php(75): WC_Order->get_qty_refunded_for_item(244) #1 /var/www/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/var/www/html/w...') #2 /var/www/html/wp-content/plugins/woocommerce/includes/wc-template-functions.php(3247): wc_get_template('emails/email-or...', Array) #3 /var/www/html/wp-content/plugins/woocommerce/templates/emails/email-order-details.php(56): wc_get_email_order_items(Object(Automattic\WooCommerce\Admin\Overrides\Order), Array) #4 /var/www/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/var/www/html/w...') #5 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-emails.php(421): wc_get_template('emails/email-or...', Array) #6 /var/www/html/wp-includes/class-wp-hook.php(287): WC_Emails->order_details(Object(Automattic\WooCommerce\Admin\Overrides\Order), false, false, Object(WC_Email_Customer_Processing_Order)) #7 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #8 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #9 /var/www/html/wp-content/plugins/woocommerce/templates/emails/customer-processing-order.php(40): do_action('woocommerce_ema...', Object(Automattic\WooCommerce\Admin\Overrides\Order), false, false, Object(WC_Email_Customer_Processing_Order)) #10 /var/www/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/var/www/html/w...') #11 /var/www/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(364): wc_get_template('emails/customer...', Array, '', '') #12 /var/www/html/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-processing-order.php(113): wc_get_template_html('emails/customer...', Array) #13 /var/www/html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(541): WC_Email_Customer_Processing_Order->get_content_html() #14 /var/www/html/wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-processing-order.php(93): WC_Email->get_content() #15 /var/www/html/wp-includes/class-wp-hook.php(287): WC_Email_Customer_Processing_Order->trigger(5335, Object(Automattic\WooCommerce\Admin\Overrides\Order)) #16 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #17 /var/www/html/wp-includes/plugin.php(551): WP_Hook->do_action(Array) #18 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-emails.php(170): do_action_ref_array('woocommerce_ord...', Array) #19 /var/www/html/wp-includes/class-wp-hook.php(287): WC_Emails::send_transactional_email(Array, Object(Automattic\WooCommerce\Admin\Overrides\Order)) #20 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #21 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #22 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-order.php(372): do_action('woocommerce_ord...', 5335, Object(Automattic\WooCommerce\Admin\Overrides\Order)) #23 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-order.php(221): WC_Order->status_transition() #24 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-order.php(119): WC_Order->save() #25 /var/www/html/wp-content/plugins/some-gateway/includes/class-some-wc-gateway-invoice.php(181): WC_Order->payment_complete() #26 /var/www/html/wp-includes/class-wp-hook.php(287): Some_WC_Gateway_Invoice->callback_handler('') #27 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #28 /var/www/html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #29 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-api.php(161): do_action('woocommerce_api...') #30 /var/www/html/wp-includes/class-wp-hook.php(287): WC_API->handle_api_requests(Object(WP)) #31 /var/www/html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #32 /var/www/html/wp-includes/plugin.php(551): WP_Hook->do_action(Array) #33 /var/www/html/wp-includes/class-wp.php(388): do_action_ref_array('parse_request', Array) #34 /var/www/html/wp-includes/class-wp.php(745): WP->parse_request('') #35 /var/www/html/wp-includes/functions.php(1291): WP->main('') #36 /var/www/html/wp-blog-header.php(16): wp() #37 /var/www/html/index.php(17): require('/var/www/html/w...') #38 {main} thrown in /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-order.php on line 1938
- The topic ‘Compatibility issue with WooCommerce 5.0.0 and Compatibility mode’ is closed to new replies.