0
votes

Fatal error: Uncaught Error: Call to a member function get_status() on null

I have WooCommerce and WooCommerce Subscriptions installed as well as YITH WooCommerce Customize My Account Page. And when I click on View Subscription, I get an error about the website having issues. When I show console in Chrome, and/or enable Debug, I get the following error message. Any help is greatly appreciated!

Fatal error: Uncaught Error: Call to a member function get_status() on null in /www/wp-content/plugins/woocommerce-subscriptions/templates/myaccount/subscription-details.php:18 Stack trace: #0 /www/wp-content/plugins/woocommerce/includes/wc-core-functions.php(249): include() #1 /www/wp-content/plugins/woocommerce-subscriptions/includes/class-wcs-template-loader.php(41): wc_get_template('myaccount/subsc...', Array, '', '/www/wp-content...') #2 /wordpress/wp-includes/class-wp-hook.php(286): WCS_Template_Loader::get_subscription_details_template(NULL) #3 /wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #4 /wordpress/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #5 /www/wp-content/plugins/woocommerce-subscriptions/templates/myaccount/view-subscription.php(23): do_action('woocommerce_sub...', NULL) #6 /www/wp-content/plugins/woocommerce/includes/wc-core-functions.php(249): include('/www/wp-content...') #7 /www/wp-content/plugins/yith-woocommerce-customize-myaccount-page/includes/functio in /www/wp-content/plugins/woocommerce-subscriptions/templates/myaccount/subscription-details.php on line 18

1

1 Answers

1
votes

Add this in your view-subscription.php file:

$subscription = wcs_get_subscription(basename($_SERVER['REQUEST_URI']));

You can find it in inside the folder woocommerce/myaccount of your theme. If you don't have it then you will have to create it by copying it from your woocommerce installation (check this link if you are not sure how it works).

That line should go just after the security check:

if ( ! defined( 'ABSPATH' ) ) {
        exit; // Exit if accessed directly
}