Title: PHP message: get_cart was called incorrectly.
Last modified: February 7, 2022

---

# PHP message: get_cart was called incorrectly.

 *  [dev](https://wordpress.org/support/users/devksec/)
 * (@devksec)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/)
 * Hello,
 * We’ve recently installed ithemes and are now getting this error. It just continues
   and is the same error repealted per line.
 * FastCGI sent in stderr: “PHP message: get_cart was called incorrectly. Get basket
   should not be called before the wp_loaded action. Backtrace: require(‘wp-blog-
   header.php’), require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘
   wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters,
   ITSEC_Lockout->check_for_host_lockouts, ITSEC_Lockout->execute_lock, wp_logout,
   do_action(‘wp_logout’), WP_Hook->do_action, WP_Hook->apply_filters, WooCommerce_Groupons::
   wp_logout, WC_Cart->remove_coupons, WC_Cart_Session->set_session, WC_Cart_Session-
   >get_cart_for_session, WC_Cart->get_cart, wc_doing_it_wrong. This message was
   added in version 2.3.PHP message: get_cart was called incorrectly. Get basket
   should not be called before the wp_loaded action. Backtrace: require(‘wp-blog-
   header.php’), require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘
   wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters,
   ITSEC_Lockout->check_for_host_lockouts, ITSEC_Lockout->execute_lock, wp_logout,
   do_action(‘wp_logout’), WP_Hook->do_action, WP_Hook->apply_filters, WooCommerce_Groupons::
   wp_logout, WC_Cart->remove_coupons, WC_Cart_Session->set_session, WC_Cart_Session-
   >get_cart_for_session, WC_Cart->get_cart, WC_Cart_Session->get_cart_from_session,
   do_action(‘woocommerce_cart_loaded_from_session’), WP_Hook->do_action, WP_Hook-
   >apply_filters, WC_Cart_Session->set_session, WC_Cart_Session->get_cart_for_session,
   WC_Cart->get_cart, wc_doing_it_wrong. This message was added in version 2.3.PHP
   message: get_cart was called incorrectly. Get basket should not be called before
   the wp_loaded action. Backtrace: require(‘wp-blog-header.php’), require_once(‘
   wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’),
   do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, ITSEC_Lockout-
   >check_for_host_lockouts, ITSEC_Lockout->execute_lock, wp_logout, do_action(‘
   wp_logout’), WP_Hook->do_action, WP_Hook->a
 * any ideas on how to resolve?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [nlpro](https://wordpress.org/support/users/nlpro/)
 * (@nlpro)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/#post-15340833)
 * Hi [@dev](https://wordpress.org/support/users/dev/),
 * Not a full solution but if you change line #792 in the better-wp-security/core/
   lockout.php file:
 * `if ( is_object( $current_user ) && isset( $current_user->ID ) ) {`
 * to:
 * `if ( $current_user instanceof WP_User && $current_user->exists() ) {`
 * the error will only occur for logged in users.
 * Currently the error occurs for both, logged in users as well as visitors (users
   not logged in). IMHO there is no point in calling wp_logout() for visitors 😉
 * Apart from the invalid condition (bug) this is definately a plugin conflict. 
   The iTSec plugin lockout feature (aka Brute Force Protection) hooks into the **
   init** action which is executed (just) before the **wp_loaded** action.
 * +++++ To prevent any confusion, I’m not iThemes +++++
 * [@timothyblynjacobs](https://wordpress.org/support/users/timothyblynjacobs/)
 * At least fix the invalid condition, another surviving dinosaur 😉
    -  This reply was modified 4 years, 3 months ago by [nlpro](https://wordpress.org/support/users/nlpro/).
 *  Thread Starter [dev](https://wordpress.org/support/users/devksec/)
 * (@devksec)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/#post-15341347)
 * I’ve added that code in, thanks 🙂
 * Will keep an eye out.
 * Could it be wordfence, if so is there a guide on how now to conflict ?
 *  [nlpro](https://wordpress.org/support/users/nlpro/)
 * (@nlpro)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/#post-15362195)
 * Got my hands on the **Woocommerce Group Coupons** plugin. Found an alternative
   method to prevent this error from happening.
 * In WordPress Dashboard navigate to the **Woocommerce->Group Coupons** menu option.
   You should see a similar settings page like [this](https://woocommerce.com/wp-content/uploads/2013/06/group-coupons-settings.png).
 * If currently enabled, disable the **Remove coupons after logout.** setting. Then
   click on the **Save** button.
 * Contact ITTHINX if having doubts about disabling the setting 😉
 *  [nlpro](https://wordpress.org/support/users/nlpro/)
 * (@nlpro)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/#post-15486352)
 * Accoding to the 8.1.0 Changelog:
 * > Bug Fix: Compatibility with plugins that expected a logged-in user during lockouts.
 * Checked the code and I can confirm the invalid condition bug has been fixed 😉

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP message: get_cart was called incorrectly.’ is closed to new replies.

 * ![](https://ps.w.org/better-wp-security/assets/icon.svg?rev=3529351)
 * [Kadence Security – Password, Two Factor Authentication, and Brute Force Protection](https://wordpress.org/plugins/better-wp-security/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-wp-security/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-wp-security/)
 * [Active Topics](https://wordpress.org/support/plugin/better-wp-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-wp-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-wp-security/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [nlpro](https://wordpress.org/support/users/nlpro/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/php-message-get_cart-was-called-incorrectly/#post-15486352)
 * Status: not resolved