• Resolved falkemediawy

    (@falkemediawy)


    Hi there,

    since the last update to version 8.6.0 we receive an error on the cart page. It says that in the file /plugins/woocommerce-payments/includes/class-wc-payments.php on line 1887 the variable $cart_contains_subscription isn’t defined.

    Well, yes, it isn’t defined if the if-condition above it is not executed (the variable is initialized inside the if). I fixed it by initializing it with “false” right below where $is_subscription is initialized (line 1879).

    Would be nice if this issue is fixed in the next update!

    Cheers,
    Lisa

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter falkemediawy

    (@falkemediawy)

    I kept the variable in place and only added a default value at the beginning of the function:

    	/**
    * Load stripe site messaging script.
    *
    * @return void
    */
    public static function load_stripe_bnpl_site_messaging() {
    // The messaging element shall not be shown for subscription products.
    // As we are not too deep into subscriptions API, we follow simplistic approach for now.
    $is_subscription = false;
    $cart_contains_subscription = false; // this line is the new one :)
    $are_subscriptions_enabled = class_exists( 'WC_Subscriptions' ) || class_exists( 'WC_Subscriptions_Core_Plugin' );
    if ( $are_subscriptions_enabled ) {
    global $product;
    $is_subscription = $product && WC_Subscriptions_Product::is_subscription( $product );
    $cart_contains_subscription = is_cart() && WC_Subscriptions_Cart::cart_contains_subscription();
    }

    if ( ! $is_subscription && ! $cart_contains_subscription ) {
    require_once __DIR__ . '/class-wc-payments-payment-method-messaging-element.php';
    $stripe_site_messaging = new WC_Payments_Payment_Method_Messaging_Element( self::$account, self::$card_gateway );
    echo wp_kses( $stripe_site_messaging->init() ?? '', 'post' );
    }
    }
    • This reply was modified 2 months, 3 weeks ago by falkemediawy.
    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello falkemediawy,

    Thank you for contacting WooCommerce support.

    I appreciate your time and effort in reporting this issue along with the solution.
    It is already being helpful for other users.

    I will double-check this issue and notify the relevant team.

    Have a great day!

    Plugin Support Adam Heckler

    (@adamkheckler)

    We have a fix for this going out in the next release. ??

    Thread Starter falkemediawy

    (@falkemediawy)

    Thank you for the quick fix @adamkheckler !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘$cart_contains_subscription is undefined’ is closed to new replies.