• Resolved gerobe

    (@gerobe)


    Hello WooCommerce PayPal Payments Support Team,

    I’ve encountered a compatibility issue between the “WooCommerce PayPal Payments” plugin and the “Subscribe To Comments Reloaded” plugin on my WordPress site.

    Issue Summary: When “WooCommerce PayPal Payments” is active, accessing the subscription management page provided by “Subscribe To Comments Reloaded” results in a critical error. The error log indicates a type error in the function WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector::has_elementor_checkout(), where a string is passed instead of the expected integer.

    Error Log Extract:

    PHP Fatal error:  Uncaught TypeError: WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector::has_elementor_checkout(): Argument #1 ($page_id) must be of type int, string given, called in /wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-compat/src/CompatModule.php on line 332

    Root Cause: The issue seems to occur because the function get_the_ID() may return null or a non-integer value on certain pages, leading to the type error when passed to has_elementor_checkout().

    Proposed Solution: I’ve modified the set_elementor_checkout_context() function in CompatModule.php to ensure that the code only runs on actual checkout pages and that the $page_id is properly validated and cast to an integer before being passed to has_elementor_checkout().

    Here’s the adjusted code:

    protected function set_elementor_checkout_context(): void {
    add_action(
    'wp',
    function() {
    // Ensure the code only runs on checkout pages
    if ( ! is_checkout() ) {
    return;
    }

    $page_id = get_the_ID();

    // Ensure $page_id is a valid int
    if ( ! $page_id || ! is_numeric( $page_id ) || ! CartCheckoutDetector::has_elementor_checkout( (int) $page_id ) ) {
    return;
    }

    add_filter(
    'woocommerce_paypal_payments_context',
    function ( string $context ): string {
    // Default context.
    return ( 'mini-cart' === $context ) ? 'checkout' : $context;
    }
    );
    }
    );
    }

    This change resolved the issue on my site. I wanted to bring this to your attention in case other users experience similar problems, and to suggest that this or a similar fix might be integrated into a future update.

    Thank you for your attention to this matter, and for your continued work on this excellent plugin!

    Best regards,

Viewing 1 replies (of 1 total)
  • Plugin Support Syde Jamie

    (@jamieong)

    Hello @gerobe,

    Thank you for letting us know that the change resolved the issue on your site. We appreciate you bringing this to our attention and for suggesting the integration of a similar fix in future updates. Your feedback is invaluable, and we’re glad to hear that you’re enjoying the plugin. Thank you for your continued support!

    Best Regards,
    Jamie

Viewing 1 replies (of 1 total)
  • The topic ‘Compatibility Issue with “Subscribe To Comments Reloaded” Plugin’ is closed to new replies.