Cart not empty after logout
-
Hey friends,
Have a problem. Use Woocommerce.
Situation:
Connect as admin, add to cart few prods, log out -> same prods exist, login as another simple user -> same cart with same prods.tried to find conflict between plugins – did not.
Tried edit functions.php
/*empty cart if user come to homepage*/ add_action( ‘init’, ‘woocommerce_clear_cart_url’ ); function woocommerce_clear_cart_url() { global $woocommerce; if ($_SERVER[‘REQUEST_URI’] === ‘/’) { $woocommerce->cart->empty_cart(); } }
, tried this
function log_function_cart() { global $woocommerce; $woocommerce->cart->empty_cart(); } add_action(‘clear_auth_cookie’, ‘log_function_cart’);
and few other, but not working..
Use WP 5.7.2
PHP v.: 7.2
Woocommerce: 5.3.0few days ago installed login logout register plugin and forminator, worked well and after a day~ happened this.. tried to deactivate these – same, tried deactivate all plugins (what I installed) – same.. tried to clear cash, try different browser, asked host company to check cash on server – same..
what could be possible to solve this issue?
new code to functions.php?
-
Hi @mamandis,
Do you happen to have any caching plugins installed? They could cause the contents of a cart to persist after purchase and even display the cart of one user elsewhere. We have a guide on how to configure caching plugins correctly: https://docs.woocommerce.com/document/configuring-caching-plugins/
Also, could you please share a copy of your site’s System Status? You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”.? Once you’ve done that, paste it here in your response.
Thanks.
Thanks for fast response @abwaita ??
Yeah, I installed WP Fastest Cache plugin (do not remember, installed it before or after this problem). Now tried to deactivate plugin, tried different browsers – same (prods exists).Here is my report:
### WordPress Environment ### WordPress address (URL): https://www.mixngo.eu Site address (URL): https://www.mixngo.eu WC Version: 5.3.0 REST API Version: ? 5.3.0 WC Blocks Version: ? 4.9.1 Action Scheduler Version: ? 3.1.6 WC Admin Version: ? 2.2.6 Log Directory Writable: ? WP Version: 5.7.2 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ? Language: en External object cache: – ### Server Environment ### Server Info: Apache PHP Version: 7.2.34 PHP Post Max Size: 64 MB PHP Time Limit: 300 PHP Max Input Vars: 10000 cURL Version: 7.72.0 OpenSSL/1.0.2k-fips SUHOSIN Installed: – MySQL Version: 5.5.5-10.3.25-MariaDB-log Max Upload Size: 64 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 5.3.0 WC Database Prefix: j6pl_ Total Database Size: 25.45MB Database Data Size: 22.82MB Database Index Size: 2.63MB j6pl_woocommerce_sessions: Data: 0.31MB + Index: 0.02MB + Engine MyISAM j6pl_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_order_items: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_order_itemmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_tax_rates: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woocommerce_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_actionscheduler_actions: Data: 0.01MB + Index: 0.02MB + Engine MyISAM j6pl_actionscheduler_claims: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_actionscheduler_groups: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_actionscheduler_logs: Data: 0.01MB + Index: 0.01MB + Engine MyISAM j6pl_apmm_custom_theme: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_aws_cache: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_aws_index: Data: 0.17MB + Index: 0.09MB + Engine MyISAM j6pl_cartflows_ca_cart_abandonment: Data: 0.01MB + Index: 0.01MB + Engine MyISAM j6pl_cartflows_ca_email_history: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_cartflows_ca_email_templates: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_cartflows_ca_email_templates_meta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_check_email_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_commentmeta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_comments: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_fbv: Data: 0.02MB + Index: 0.02MB + Engine InnoDB j6pl_fbv_attachment_folder: Data: 0.02MB + Index: 0.00MB + Engine InnoDB j6pl_frmt_form_entry: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_frmt_form_entry_meta: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_frmt_form_views: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_links: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_media_folders_lists: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_media_folder_file_relationship: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_mgmlp_folders: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_options: Data: 4.45MB + Index: 0.11MB + Engine MyISAM j6pl_pmxi_files: Data: 0.01MB + Index: 0.00MB + Engine MyISAM j6pl_pmxi_hash: Data: 0.17MB + Index: 0.11MB + Engine MyISAM j6pl_pmxi_history: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_pmxi_images: Data: 0.20MB + Index: 0.03MB + Engine MyISAM j6pl_pmxi_imports: Data: 1.31MB + Index: 0.00MB + Engine MyISAM j6pl_pmxi_posts: Data: 0.09MB + Index: 0.02MB + Engine MyISAM j6pl_pmxi_templates: Data: 0.04MB + Index: 0.00MB + Engine MyISAM j6pl_postmeta: Data: 12.54MB + Index: 0.61MB + Engine MyISAM j6pl_posts: Data: 2.20MB + Index: 0.28MB + Engine MyISAM j6pl_termmeta: Data: 0.01MB + Index: 0.02MB + Engine MyISAM j6pl_terms: Data: 0.01MB + Index: 0.02MB + Engine MyISAM j6pl_term_relationships: Data: 0.01MB + Index: 0.03MB + Engine MyISAM j6pl_term_taxonomy: Data: 0.01MB + Index: 0.01MB + Engine MyISAM j6pl_trp_dictionary_en_us_en: Data: 0.01MB + Index: 0.02MB + Engine MyISAM j6pl_trp_dictionary_en_us_fr_fr: Data: 0.03MB + Index: 0.06MB + Engine MyISAM j6pl_trp_gettext_en: Data: 0.02MB + Index: 0.04MB + Engine MyISAM j6pl_trp_gettext_en_us: Data: 0.26MB + Index: 0.42MB + Engine MyISAM j6pl_trp_gettext_fr_fr: Data: 0.14MB + Index: 0.18MB + Engine MyISAM j6pl_trp_original_meta: Data: 0.01MB + Index: 0.02MB + Engine MyISAM j6pl_trp_original_strings: Data: 0.02MB + Index: 0.03MB + Engine MyISAM j6pl_usermeta: Data: 0.04MB + Index: 0.03MB + Engine MyISAM j6pl_users: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_user_registration_sessions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wccs_conditions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wccs_condition_meta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_admin_notes: Data: 0.01MB + Index: 0.00MB + Engine MyISAM j6pl_wc_admin_note_actions: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_category_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_customer_lookup: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wc_download_log: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_order_coupon_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_order_product_lookup: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wc_order_stats: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wc_order_tax_lookup: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_product_meta_lookup: Data: 0.08MB + Index: 0.12MB + Engine MyISAM j6pl_wc_reserved_stock: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wc_tax_rate_classes: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wc_webhooks: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wdr_order_discounts: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wdr_order_item_discounts: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wdr_rules: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_woof_query_cache: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wpforms_tasks_meta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wpmailsmtp_tasks_meta: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wpml_mails: Data: 0.47MB + Index: 0.00MB + Engine MyISAM j6pl_wps_hit: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wps_index: Data: 0.11MB + Index: 0.15MB + Engine MyISAM j6pl_wps_key: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wps_object_type: Data: 0.00MB + Index: 0.01MB + Engine MyISAM j6pl_wps_query: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wps_uri: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_wps_user_agent: Data: 0.00MB + Index: 0.00MB + Engine MyISAM j6pl_yith_wcwl: Data: 0.01MB + Index: 0.01MB + Engine MyISAM j6pl_yith_wcwl_lists: Data: 0.01MB + Index: 0.01MB + Engine MyISAM ### Post Type Counts ### attachment: 2073 cartflows_flow: 1 cartflows_step: 2 cmm4e_menu: 1 cmm4e_menu_theme: 1 custom_css: 3 elementor_library: 1 elementor-hf: 1 elementskit_content: 4 elementskit_template: 1 forminator_forms: 2 groovy_menu_preset: 1 language_switcher: 3 mgmlp_media_folder: 11 nav_menu_item: 35 page: 45 polylang_mo: 2 post: 2 postman_sent_mail: 70 product: 73 product_variation: 258 revision: 667 shop_coupon: 2 shop_order: 1 user_registration: 2 wpcf7_contact_form: 1 wpforms: 1 wpmm_theme: 3 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (33) ### Elementor Addon Elements: by WPVibes – 1.11.5 Advanced Woo Search: by ILLID – 2.28 Antispam Bee: by pluginkollektiv – 2.9.4 Starter Templates: by Brainstorm Force – 2.6.10 CartFlows: by CartFlows Inc – 1.6.14 Check & Log Email: by WPChill – 1.0.1 Child Theme Configurator: by Lilaea Media – 2.5.8 Contact Form 7: by Takayuki Miyoshi – 5.4.1 Custom Fonts: by Brainstorm Force – 1.3.2 Duplicate Page: by mndpsingh287 – 4.4 Elementor: by Elementor.com – 3.2.4 FileBird Lite: by Ninja Team – 4.7.3 First Order Discount Woocommerce: by WooExtend – 1.19 Forminator: by WPMU DEV – 1.14.11 Elementor - Header, Footer & Blocks: by Brainstorm Force Nikhil Chavan – 1.5.9 Health Check & Troubleshooting: by The www.remarpro.com community – 1.4.5 Hello Dolly: by Matt Mullenweg – 1.7.2 Login Logout Register Menu: by Vinod Dalvi – 2.0 Max Mega Menu: by megamenu.com – 2.9.3 Post SMTP: by Yehuda Hassine – 2.0.23 Premium Addons for Elementor: by Leap13 – 4.3.6 Really Simple SSL: by Really Simple Plugins – 4.0.15 Shortcode in Menus: by Gagan Deep Singh – 3.5.1 UpdraftPlus - Backup/Restore: by UpdraftPlus.Com DavidAnderson – 1.16.56 WooCommerce PayPal Checkout Gateway: by WooCommerce – 2.1.1 WooCommerce Stripe Gateway: by WooCommerce – 5.2.0 WOOF - WooCommerce Products Filter: by realmag777 – 1.2.5.3 WooCommerce: by Automattic – 5.3.0 WP All Import Pro: by Soflyy – 4.6.7 WP Mail Logging: by MailPoet – 1.9.7 WP Media Manager Lite: by AccessPress Themes – 1.1.2 WP All Import - WooCommerce Add-On Pro: by Soflyy – 3.2.6 YITH WooCommerce Wishlist: by YITH – 3.0.22 ### Inactive Plugins (1) ### WP Fastest Cache: by Emre Vona – 0.9.1.8 ### Must Use Plugins (1) ### installatron_hide_status_test.php: by – ### Settings ### API Enabled: – Force SSL: – Currency: EUR (€) Currency Position: left Thousand Separator: . Decimal Separator: , Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – ### WC Pages ### Shop base: #38 - /store/ Cart: ? Page does not contain the [woocommerce_cart] shortcode or the woocommerce/cart block. Checkout: #40 - /checkout/ My account: #41 - /my-account/ Terms and conditions: ? Page not set ### Theme ### Name: Astra Child Version: 2.4.5.1603815700 Author URL: https://wpastra.com/about/ Child Theme: ? Parent Theme Name: Astra Parent Theme Version: 3.4.7 Parent Theme Author URL: https://wpastra.com/about/ WooCommerce Support: ? ### Templates ### Overrides: – ### Action Scheduler ### Complete: 55 Oldest: 2021-05-09 20:28:30 +0000 Newest: 2021-06-02 11:00:26 +0000 ### Status report information ### Generated at: 2021-06-02 13:01:56 +02:00
- This reply was modified 3 years, 5 months ago by mamandis.
Thanks for getting back.
Just to be sure that you’re doing it right, kindly follow this sequence:
1. Delete all cache from WP Fastest Cache – here’s an article that explains how to do it: https://www.hostinger.com/tutorials/wordpress/how-to-clear-wordpress-cache#Clear_Cache_with_WP_Fastest_Cache
2. Clear cache from your browsers – you can find more info here: https://wordpress.com/support/browser-issues/#clearing-your-browser-cache
3. Check if the problem persists.Thanks.
@abwaita ,
I done steps you told me – 1. deleted all cache (my simple manual you gave) and 2. deleted browser’s cache, refreshed page, for a couple of mili seconds showed 0 (items in cart) and immediately showed same items in cart -> still same problem..
What you could tell to try more to solve this issue? ??
Hi @mamandis ??
/*empty cart if user come to homepage*/ add_action( 'init', 'woocommerce_clear_cart_url' ); function woocommerce_clear_cart_url() { global $woocommerce; if ($_SERVER['REQUEST_URI'] === '/') { $woocommerce->cart->empty_cart(); } }
I’ve tried this code on my end, and it worked great! I would recommend using the Code Snippet plugin in order to add custom PHP code into your site without having to touch the
functions.php
file. Here is a link on how to use the Code Snippet plugin:Also, update your PHP to version 7.4.1 to see if that helps ??
Cheers!
Thanks for helping, @gabrielfuentes ??
but this code, you gave me, deleting cart when you access home page every time.. but I do not want so.. Couse, lets say, I pick one prod to my cart, go back to take another from home page, I see zero in my cart.. ??
I try to find what is bad that happened so.. :#
Any other ideas?
Oh! I see!
Any other ideas?
Yes, add a
woocommerce_persistent_cart_enabled
filter to disable the persistent cart. To do this, please use the following code, I tested it, and it worked like a charm ??add_filter( 'woocommerce_persistent_cart_enabled', '__return_false' );
Cheers!
Hi @mamandis,
We’ve not heard back from you in a while so I’ll go ahead and mark this thread as resolved. I hope you will find the above information useful.
If you have other WooCommerce Core plugin issues, please feel free to create a new thread on the forum.
Thanks.
- The topic ‘Cart not empty after logout’ is closed to new replies.