Support » Plugin: WooCommerce Stripe Payment Gateway » 2 fatal checkout page errors

  • Resolved swissspaceboy

    (@swissspaceboy)


    Hi,

    I am using the latest version 4.5.5 and 2 critical errors show up when going to the checkout page. I had to fix the code to show the checkout page and to avoid the freeze. I am NOT using the Woocommerce subscription module, but another product.

    1. error

    
    2020-11-27T16:11:38+00:00 CRITICAL Uncaught Error: Call to undefined function wcs_user_has_subscription() in /xxx/wp-content/plugins/woocommerce-gateway-stripe/includes/compat/class-wc-stripe-subs-compat.php:89

    -> the function “wcs_user_has_subscription” does not exist so you need to check before using it. I change to this code:

    ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( get_current_user_id(), '', $subs_statuses ) ) &&

    2. error

    2020-11-27T16:05:44+00:00 CRITICAL Uncaught Error: Class 'WC_Subscriptions_Product' not found in /xxx/wp-content/plugins/woocommerce-gateway-stripe/includes/payment-methods/class-wc-stripe-payment-request.php:678

    -> the check on the class WC_Subscriptions_Order is wrong. I changed to this code:

    
    if ( class_exists( 'WC_Subscriptions_Product' ) && $product->needs_shipping() && WC_Subscriptions_Product::get_trial_length( $product ) > 0 ) {

    Please check and fix.

    Thanks,

    Didier.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support AW

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    This sounds like perhaps the plugin didn’t install all the way, like it’s missing a file.

    There are no other reports of this, and these errors are not showing on test sites with the same version of the Stripe plugin.

    Can you delete and reinstall the plugin and check again?

    Hi,

    Thanks for the reply.

    I cannot delete for a production site, but I will download the latest plugin version and see if I can find the function “wcs_user_has_subscription” in the code. If you are right, this function should be present.

    I will check today.

    Thanks,

    Didier.

    Hello,

    Not better.

    1. I download the latest plugin code 4.5.5
    2. I search in all the code for the string “wcs_user_has_subscription”. It doesn’t exist.

    So where is this function wcs_user_has_subscription() defined ?

    Now, as I did your homework, I can find this function in the Woocommerce Subscriptions module, that I am NOT USING and that is not installed.

    I don’t think that the Stripe module needs this premium subscription plugin to work.

    Please review & fix.

    Thanks,

    Didier.

    Plugin Support AW

    (@slash1andy)

    Automattic Happiness Engineer

    Hey again!

    This is still the same issue that I was mentioning before: There seems to be an issue with the installation, as all the plugin files don’t seem to be there.

    In Stripe, we include code for compatibility for some plugins, in this case, it’s WooCommerce Subscriptions. This *is* a part of Stripe plugin, not something else, as you suggest.

    You can see the exact line your error is referring to here: https://github.com/woocommerce/woocommerce-gateway-stripe/blob/84b6457d691f47bdbcaa45f4d218ba852532c857/includes/compat/class-wc-stripe-subs-compat.php#L89

    Since this function *does* exist in the Stripe plugin but not on your site, this issue you are seeing is 100% isolated to your install, and there are no other reports of this issue, including on my test site. This indicates there’s an issue specifically with your site, not with the plugin in general.

    Thanks.

    Can you tell me in which file the Stripe plugin has defined the function “wcs_user_has_subscription()”? I can search for that. We are talking in the blind for a while.

    Many thanks,

    Didier.

    Hello,

    So as said before, I have another subscription module that works with Stripe. So I do not use the Woocommerce Subscription module. I do not have the function wcs_user_has_subscription() in all my WordPress code. Maybe it is required for Stripe. Could be.

    So as the function wcs_user_has_subscription() is NOT defined in the Stripe plugin, but elsewhere, you MUST check for the existence of the function before using it. This is basic code quality.

    Please review and fix.

    Thanks,

    Didier.

    Plugin Support AW

    (@slash1andy)

    Automattic Happiness Engineer

    Hey again!

    I sent the name of the file in the link. Here it is again: https://github.com/woocommerce/woocommerce-gateway-stripe/blob/84b6457d691f47bdbcaa45f4d218ba852532c857/includes/compat/class-wc-stripe-subs-compat.php#L89

    It’s also found in the error message you sent in initially: 2020-11-27T16:11:38+00:00 CRITICAL Uncaught Error: Call to undefined function wcs_user_has_subscription() in /xxx/wp-content/plugins/woocommerce-gateway-stripe/includes/compat/class-wc-stripe-subs-compat.php:89

    So as the function wcs_user_has_subscription() is NOT defined in the Stripe plugin, but elsewhere, you MUST check for the existence of the function before using it. This is basic code quality.

    It is found in the Stripe plugin code, and is called in the Stripe plugin code. This issue (where it doesn’t appear on your site), as I said in my initial response, likely because there was an installation issue and the file didn’t transfer.

    Marking this as resolved, as there is not an issue in the plugin, only in your installation. This can be solved in reinstallation.

    Hello,

    Sorry, but which word do you not understand? I ask you to tell me in which file of Stripe you have defined the function wcs_user_has_subscription() as you say this function is delivered with Stripe. You send me the line of code that calls this function wcs_user_has_subscription(). I know that it is called on this line, as this is the line that crashes on my site. And this line I fixed locally.

    I re-installed the latest plugin version of Stripe, and I still have both errors as the function wcs_user_has_subscription() DOES NOT EXIST in the Stripe plugin.

    In what language do I need to say it? Please give me the FILENAME where the function wcs_user_has_subscription() is DEFINED/CODED/WRITTEN?

    In case you do not know what I am talking about, please check with a senior engineer who can help me out on this ticket.

    Thanks,

    Didier.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.