• Hallo

    Das Plugin WC Global Cart führt zu einem fatalen Fehler in Swiss QR Bill.

    In abstract-wc-gateway-swiss-qr-bill.php auf Zeile 263 wird false anstelle eines Objektes zurückgegeben. Laut API-Doku von WooCommerce kann wc_get_product(..) false oder null zurückgeben.

    Vorschlag / Wunsch. Prüfung auf false / null einfügen. Patch:

    Index: includes/gateway/abstract-wc-gateway-swiss-qr-bill.php
    ===================================================================
    --- includes/gateway/abstract-wc-gateway-swiss-qr-bill.php	(revision 2747982)
    +++ includes/gateway/abstract-wc-gateway-swiss-qr-bill.php	(working copy)
    @@ -262,6 +262,10 @@
             foreach (WC()->cart->get_cart_contents() as $cart_content):
                 $cart_product = wc_get_product($cart_content['product_id']);
     
    +			if (is_null($cart_product) or $cart_product == false) {
    +				return true;
    +			}
    +
                 foreach ($cart_product->get_category_ids() as $category_id):
                     $is_gateway_enabled = get_term_meta($category_id, 'wsqb_activate_gateway', true) !== 'no';
                     // Return false as soon as we find disabled category
    
    
    Error_log mit Stacktrace:
    

    [25-Jun-2022 15:31:16 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_category_ids() on bool in —-/wordpress/wp-content/plugins/swiss-qr-bill/includes/gateway/abstract-wc-gateway-swiss-qr-bill.php:265
    Stack trace:
    #0 —-/wordpress/wp-content/plugins/swiss-qr-bill/includes/gateway/abstract-wc-gateway-swiss-qr-bill.php(148): WC_Gateway_Swiss_Qr_Base->check_product_cats_restriction()
    #1 —-/wordpress/wp-content/plugins/woocommerce/includes/class-wc-payment-gateways.php(154): WC_Gateway_Swiss_Qr_Base->is_available()
    #2 —-/wordpress/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php(799): WC_Payment_Gateways->get_available_payment_gateways()
    #3 —-/wordpress/wp-includes/class-wp-hook.php(307): WC_Stripe_Payment_Request->display_payment_request_button_html(”)
    #4 —-/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters in —-/wordpress/wp-content/plugins/swiss-qr-bill/includes/gateway/abstract-wc-gateway-swiss-qr-bill.php on line 265
    `

    Danke ??

  • The topic ‘Uncaught Error: Call to a member function get_category_ids() on bool’ is closed to new replies.