Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

Fix "Call to undefined function wc_notice_count()" error while editing customer in admin #558

Closed james-allan closed 5 months ago

james-allan commented 5 months ago

Fixes #https://github.com/woocommerce/woocommerce-subscriptions/issues/4605

Description

This PR fixes an error that occurs on the latest WC version 8.5.1 when editing a customer in the admin dashboard.

PHP Fatal error:  Uncaught Error: Call to undefined function wc_notice_count() in app/public/wp-content/plugins/woocommerce-subscriptions/vendor/woocommerce/subscriptions-core/includes/class-wc-subscriptions-addresses.php:146
Stack trace:
#0 app/public/wp-includes/class-wp-hook.php(324): WC_Subscriptions_Addresses::maybe_update_subscription_addresses(10, 'billing')
#1 app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#2 app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 app/public/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-profile.php(243): do_action('woocommerce_cus...', 10, 'billing')
#4 app/public/wp-includes/class-wp-hook.php(324): WC_Admin_Profile->save_customer_meta_fields(10)
#5 app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#6 app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#7 app/public/wp-admin/user-edit.php(157): do_action('edit_user_profi...', 10)
#8 {main}

How to test this PR

  1. Install the latest WC versions (8.5.1).
  2. Go to the Users screen in your WP Dashboard.
  3. Edit a user that has at least 1 subscription.
  4. No changes to the user are needed. Just scroll to the bottom of the screen and hit the "Update Profile" button.
    • On trunk you will see the error I mentioned above.
    • On this branch there should be no error.

Product impact