Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

Illegal offset type error during checkout #3833

Open

Description

@mrsurfhunter

While using the Newspack plugin for user subscriptions, we encountered a PHP Recoverable Error in WooCommerce Subscriptions (v7.2.1). The error message is:

Mar 15/2025 17:37:31 > 2025-03-15T23:37:31.110382193Z stderr F [15-Mar-2025 23:37:31 UTC] PHP Recoverable Error: Uncaught exception 'TypeError' with message 'Illegal offset type' in /app/web/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/wcs-functions.php on line 545, request: POST /?wc-ajax=checkout, request_id: e967e093b4f5349ea14b983f851acb73

This is the line
$subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );

All the plugins and wordpress are el the latest version.

Activity

  1. yashhhYB commented on Apr 12, 2025

    @yashhhYB

    It looks like the error is happening because the $subscription_id is not the right type (it should be a string or an integer). To fix this, you can check if it's the correct type before using it like this:

    if (is_string($subscription_id) || is_int($subscription_id)) {
        $subscriptions[ $subscription_id ] = wcs_get_subscription( $subscription_id );
    } else {
        // Log the error or show a message
        error_log('Invalid subscription ID type: ' . var_export($subscription_id, true));
    }

    This will prevent the "Illegal offset type" error.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions