yithemes / yith-woocommerce-wishlist

YITH WooCommerce Wishlist gives your users the possibility to create, fill, manage and share their wishlists allowing you to analyze their interests and needs to improve your marketing strategies.
GNU General Public License v3.0
9 stars 12 forks source link

Product duplicates in wishlist after user login #25

Open ankhy-dev opened 1 year ago

ankhy-dev commented 1 year ago

After init hook, assign_to_user method converted all session’s wishlists to user wishlists, but if user had products in wishlist before (add to wishlist product X → logout → add to wishlist product X → login), then user got product duplicates in yith_wcwl table. Because this function adds user_id to records in the table without checking if the current product already assigned to user

Case: If you already have a product in the wishlist (as registered user) and add the same product as a guest(user not logged in), then after login you will have 2 records of the same product in the database, and you need to click twice the “remove product from the wishlist” button