Developer forum

Forum » Swift » Add Product to Favorites button not updating after add/remove product

Add Product to Favorites button not updating after add/remove product

Pedro Meias
Pedro Meias
Reply

Hi,

Testing on DW 9.15.3, Swift v1.19.0

Our test environment - https://dev-swiftrizzo.mydwsite1.com/

The Add to favorites button is not updating after we add or remove the product to a favorites list.

Here is a video describing the issue.

https://www.screencast.com/t/1201llFKz

 

 


Replies

 
Merethe Vrå Andersen Dynamicweb Employee
Merethe Vrå Andersen
Reply

Hi, 

This bug (13173) is fixed in 1.21.0: https://github.com/dynamicweb/Swift/releases/tag/v1.21.0
The specific fix is here: https://github.com/dynamicweb/Swift/commit/f52eb4ef6f059d4643cdb135d3b16c77d1a990f7

BR,
Merethe Vrå Andersen

 
Joakim Sjöbäck
Reply

I'm still experience this issue after implementing the fix. I've added a console.log statement for _favorites.js and seems var productButton = document.querySelector("#FavoriteBtn_" + productId)returns null, thus making the code not able to update the button classlist.(see image) I'm also running swift 1.19.

favorite_button.png
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Joakim

Did you upgrade or just copying the above change? The above change is above a lot of other changes, so you might not just be able to copy these things down as is.

Do you build the Swift js and css your self or do you use our pre-compiled version?

BR Nicolai

 
Joakim Sjöbäck
Reply

I did not upgrade Swift, so still running 1.19. I'm recompiling using webpack included in the github repo.

I copied the changes.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Joakim

Templates and JS go hand in hand - so you cannot be sure just compying code from changeset will sort things out as there are many other changesets between the versions that can affect the code. The button id is defined in ToggleFavorite template here: https://github.com/dynamicweb/Swift/blob/main/Swift/Files/Templates/Designs/Swift/Components/ToggleFavorite.cshtml#L37

What does your template look like - and what is being rendered on the page with the button? Can you find the button in markup? And what is the ID?

Your productid could contain characters that will not work in this context.

 

You must be logged in to post in the forum