Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter amlr

    (@amlr)

    Good morning,

    I’m sure the Packlink development team is working tirelessly to fix this bug, but just in case, I passed the plugin to ChatGPT, and it resolved the issue. Below is the link to the solution:
    https://chatgpt.com/share/66ffcce7-b18c-8010-8268-e3fe3f9c848d

    In case it’s still too much effort to follow the link to check it out, here is the exact line of code that needs to be changed in the file: “class-block-checkout-handler.php” (located in packlink-pro-shipping\Components\Checkout).

    In version 3.4.12 of Packlink, on line 181 (opening it with Notepad), you should change the line:

    return explode( ':', reset( $chosen_shipping_methods ) )[1];

    To this:

    if (is_array($chosen_shipping_methods) && !empty($chosen_shipping_methods)) {
        $shipping_method = reset($chosen_shipping_methods);
        if (is_string($shipping_method)) {
            $exploded_method = explode(':', $shipping_method);
            if (isset($exploded_method[1])) {
                return $exploded_method[1];
            }
        }
    }
    return ''; // Default value if conditions are not met

    This should fix the issue. I hope the Packlink team can incorporate this fix into the code.

    Thank you very much.

    Thread Starter amlr

    (@amlr)

    As I see the entire development team very concerned about the issue, below is a copy of the error message I am receiving. This error was obtained by running a local copy of my website to avoid affecting the live server, but it is the same error in the real environment:

    Fatal error: Uncaught TypeError: reset(): Argument #1 ($array) must be of type array, string given in C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\packlink-pro-shipping\Components\Checkout\class-block-checkout-handler.php:181 Stack trace: #0 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\packlink-pro-shipping\Components\Checkout\class-block-checkout-handler.php(181): reset(”) #1 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\packlink-pro-shipping\Components\Checkout\class-block-checkout-handler.php(91): Packlink\WooCommerce\Components\Checkout\Block_Checkout_Handler->get_selected_shipping_method() #2 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(324): Packlink\WooCommerce\Components\Checkout\Block_Checkout_Handler->checkout_update_drop_off(Object(WC_Order)) #3 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(”, Array) #4 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\plugin.php(517): WP_Hook->do_action(Array) #5 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\StoreApi\Routes\V1\Checkout.php(415): do_action(‘woocommerce_sto…’, Object(WC_Order)) #6 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\StoreApi\Routes\V1\Checkout.php(166): Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->create_or_update_draft_order(Object(WP_REST_Request)) #7 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\StoreApi\Routes\V1\AbstractRoute.php(126): Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->get_route_response(Object(WP_REST_Request)) #8 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\StoreApi\Routes\V1\Checkout.php(136): Automattic\WooCommerce\StoreApi\Routes\V1\AbstractRoute->get_response_by_request_method(Object(WP_REST_Request)) #9 [internal function]: Automattic\WooCommerce\StoreApi\Routes\V1\Checkout->get_response(Object(WP_REST_Request)) #10 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\Blocks\Domain\Services\Hydration.php(155): call_user_func_array(Array, Array) #11 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\Blocks\Domain\Services\Hydration.php(65): Automattic\WooCommerce\Blocks\Domain\Services\Hydration->get_response_from_controller(‘Automattic\WooC…’, ‘/wc/store/v1/ch…’) #12 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\Blocks\Assets\AssetDataRegistry.php(340): Automattic\WooCommerce\Blocks\Domain\Services\Hydration->get_rest_api_response_data(‘/wc/store/v1/ch…’) #13 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\Blocks\Assets\AssetDataRegistry.php(269): Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry->Automattic\WooCommerce\Blocks\Assets{closure}() #14 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\plugins\woocommerce\src\Blocks\Assets\AssetDataRegistry.php(385): Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry->execute_lazy_data() #15 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(324): Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry->enqueue_asset_data(”) #16 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(”, Array) #17 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\plugin.php(517): WP_Hook->do_action(Array) #18 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\script-loader.php(2246): do_action(‘wp_print_footer…’) #19 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(324): wp_print_footer_scripts(”) #20 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #21 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\plugin.php(517): WP_Hook->do_action(Array) #22 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\general-template.php(3081): do_action(‘wp_footer’) #23 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\themes\kadence\footer.php(38): wp_footer() #24 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\template.php(810): require_once(‘C:\Users\user\…’) #25 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\template.php(745): load_template(‘C:\Users\user\…’, true, Array) #26 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\general-template.php(92): locate_template(Array, true, true, Array) #27 C:\Users\user\Local Sites\”Websitename”\app\public\wp-content\themes\kadence\page.php(22): get_footer() #28 C:\Users\user\Local Sites\”Websitename”\app\public\wp-includes\template-loader.php(106): include(‘C:\Users\user\…’) #29 C:\Users\user\Local Sites\”Websitename”\app\public\wp-blog-header.php(19): require_once(‘C:\Users\user\…’) #30 C:\Users\user\Local Sites\”Websitename”\app\public\index.php(17): require(‘C:\Users\user\…’) #31 {main} thrown in C:\Users\user**\Local Sites\”Websitename”\app\public\wp-content\plugins\packlink-pro-shipping\Components\Checkout\class-block-checkout-handler.php on line 181

    There has been a critical error on this website.

    I get the same error for all versions 3.4.X. I recall that version 3.3.4 works correctly.

    Thank you very much

    Thread Starter amlr

    (@amlr)

    I have solved, sorry for the inconveniences

Viewing 3 replies - 1 through 3 (of 3 total)