• Hi!

    After upgrading to the last version of the plugin we’ve experienced fatal errors when accessing the backend, with the following backtrace:

    Uncaught Error: Call to a member function get_cart() on null in /var/www/wp-content/plugins/afterpay-gateway-for-woocommerce/class/WC_Gateway_Afterpay.php:826
    Stack trace:
    #0 /var/www/wp-content/plugins/afterpay-gateway-for-woocommerce/class/WC_Gateway_Afterpay.php(2515): WC_Gateway_Afterpay->cart_products_are_supported()
    #1 /var/www/wp-content/plugins/afterpay-gateway-for-woocommerce/class/WC_Gateway_Afterpay_Blocks_Support.php(70): WC_Gateway_Afterpay->get_cart_placement_attributes()
    #2 /var/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Payments/PaymentMethodRegistry.php(62): WC_Gateway_Afterpay_Blocks_Support->get_payment_method_data()
    #3 /var/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/Payments/Api.php(92): Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry->get_all_registered_script_data()
    #4 /var/www/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\Payments\Api->add_payment_method_script_data('')
    #5 /var/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
    #6 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #7 /var/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/BlockTypes/MiniCart.php(201): do_action('woocommerce_blo...')
    #8 /var/www/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/BlockTypes/AbstractBlock.php(100): Automattic\WooCommerce\Blocks\BlockTypes\MiniCart->enqueue_data()
    #9 /var/www/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\BlockTypes\AbstractBlock->enqueue_editor_assets('')
    #10 /var/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #11 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #12 /var/www/wp-admin/edit-form-blocks.php(272): do_action('enqueue_block_e...')
    #13 /var/www/wp-admin/post.php(187): require('/var/www/...')
    #14 {main}
      thrown in /var/www/wp-content/plugins/afterpay-gateway-for-woocommerce/class/WC_Gateway_Afterpay.php on line 826
    

    I’ve fixed this problem by replacing, in WC_Afterpay_Gateway.php, the line 825 from:

    if (did_action('wp_loaded')) {

    To:

    if (did_action('wp_loaded') && WC()->cart)) {

    Please consider releasing a new version with this patch.

Viewing 1 replies (of 1 total)
  • Hi @davefx,

    Thank you for your report and suggestion.

    Could the version of the Afterpay Gateway for Woocommerce plugin that is installed on the website please be confirmed? In the latest version (3.7.3) any time the wp_loaded action is checked, WC()->cart is also checked.

    Version 3.7.0 (released on Oct 31, 2023) patched one instance of the wp_loaded check and version 3.7.3 (released on Dec 13, 2023) patched the other two.

    Thank you.

Viewing 1 replies (of 1 total)

The topic ‘Fatal error after upgrading to last version (with fix)’ is closed to new replies.