Wishlist without page reloads: products are added to and removed from the wishlist via AJAX and the header updates at once. After logging in, the customer is no longer sent back to a wishlist action that only accepts POST.
- The Add to Wish List buttons (
[data-action="add-to-wishlist"]) and the remove buttons of the wishlist sidebar post via AJAX: the button reads Adding..., then Added to Wish List, and the wishlist block is refreshed in place. - The AJAX actions answer JSON:
{"success": true}with the refreshed wishlist block when done,{"success": false, "error": "not_saved", "message": "..."}when Magento refused the action (the error message it added). Only a success marks the button as added. - Products already in the customer's wishlist get the class
addedon their Add to Wish List button on every page, from the customer'swishlistsection data — style it as a filled heart. - For a guest, the AJAX add/remove/update answers JSON
{"success": false, "error": "not_logged_in"}instead of a redirect; the button gets its own text back and the guest is sent to the login page, as without AJAX. After logging in, Magento completes the add it kept in the session. - After logging in, Magento sends the customer back to the URL they came from. When that is a wishlist action that only accepts POST (
remove,update,cart,allcart,fromcart,send,updateitemoptions), the return was a GET and ended in a 404; the module drops such URLs and the usual login redirect applies. - Luma-based themes (jQuery and RequireJS).
None.
Webcode's free modules are installed from our own Composer repository — they are not published on Packagist.
composer config repositories.webcode composer https://repo.webcode.bg/public
composer require webcode/module-wishlist
bin/magento module:enable Webcode_Wishlist
bin/magento setup:upgradeMagento Open Source and Mage-OS 2.4.7–2.4.9, PHP 8.3–8.5.
OSL-3.0 and AFL-3.0, like Magento itself.
Made by Webcode, a Magento development and support studio from Bulgaria. Module page: https://webcode.bg/en/wishlist.