• When JS is disabled, and on a product page you click the add to wishlist button, you receive both a success notification (product added to wishlist) and an error notification (product already exists in wishlist) when the page reloads.

    It appears that after the product is added to the wishlist, the plugin is doing a 301 redirect which then attempts to add the product a second time.

    This results in both a success and error notification at the same time, rather than just a single success notification.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi

    I tested on my local installation, but I couldn’t replicate the issue

    The Add to Wishlist url should look like the following: <your current url>?add_to_wishlist=<product id>
    When I visit it, the product gets added to the wishlist, but I do not experience any redirection (add_to_wishlist query string remains in the url)

    Could you please double check the 301 and let me know the exact url that you visit, and the Location that you get on your response headers?
    Could ou please repeat your test enabling just YITH WooCommerce Wishlist & WooCommerce, and activating Twenty as theme?

    Thread Starter 1stwebdesigns

    (@1stwebdesigns)

    Thanks for looking into this.

    Part of the issue might be that the add to wishlist URL on our site looks like this:

    <your current url>?page&product=<product name>&post_type=product&name=<product name>&add_to_wishlist=<product id>

    I tried switching to the Twenty Twenty theme and the URL was still the same.

    Temporarily I have copied the add-to-wishlist-button.php template file to our theme directory and changed the URL to what you suggested above, and this fixes the issue for now.

    Do you think there is a better way of resolving this?

    Plugin Author YITHEMES

    (@yithemes)

    I repeated my test, disabling pretty permalinks
    Now my add to wishlist links appear like this

    <my site>?product=cap&post_type=product&name=cap&add_to_wishlist=60
    

    Anyway, I still cannot reproduce the issue: when I visit this url, product page is correctly loaded, “Added to wishlist” message appears, but no error is displayed

    Besides, checking Network tab in Dev tools, I cannot see any redirection triggered during page load
    Maybe the problem is related to your specific site configuration; do you experience 301 during page loading in other pages?

    Thread Starter 1stwebdesigns

    (@1stwebdesigns)

    Thanks for taking a look.

    I tried disabling pretty permalinks and my add to wish list link is then the same as yours above. Also, adding to the wishlist works correctly with just a single success message.

    For some reason though, with pretty permalinks enabled, I do not get the correct add to wishlist URL, instead I get:

    <your current url>?page&product=<product name>&post_type=product&name=<product name>&add_to_wishlist=<product id>

    Which results in the redirect and the double message. This happens even with the Twenty Twenty theme, so I don’t think it’s theme related. The 301 redirect only happens with the Add To Wishlist URL, we aren’t experiencing any other redirects when checking via the the network tab in developer tools.

    I can email the website in question if you’re interested.

    In the meantime I have overridden the wishlist button template file to overcome the problem.

    Plugin Author YITHEMES

    (@yithemes)

    I’m afraid I have no specific suggestion in this case

    If you could share with us url of your site, I’d be glad to double check
    I’d prefer to keep this conversation entirely on the forum, since asking you to contact us outside of this platform would be against forum rules

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘When JS is disabled, adding product to wishlist is attempted twice’ is closed to new replies.