hot-fix: differentiate 'Add to Cart' and 'Go to Cart' buttons by using separate class names #296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a small but important issue regarding the behavior of the "Add to Cart" and "Go to Cart" buttons.
Problem: Both buttons shared the same class and properties, making it difficult to differentiate between them and apply specific functions. Specifically, when the "Go to Cart" button was clicked, the logic for the "Add to Cart" button was still being triggered, causing the cart-checking logic to execute incorrectly.
Solution: I have updated the button logic to distinguish between the "Add to Cart" and "Go to Cart" buttons by modifying the class names and event handlers.
Functionality:
When the "Add to Cart" button is clicked, the function checks if the cart already contains an item. If not, it adds the product to the cart.
When the "Go to Cart" button is clicked, it triggers the Go to Cart function, without interfering with the "Add to Cart" logic.
This allows for correct behavior based on which button is pressed.
Technical Details:
I updated the classes for the "Add to Cart" and "Go to Cart" buttons to make them distinct.
The logic ensures that only the appropriate function is triggered when each button is clicked, avoiding unwanted cart-checking when navigating to the cart.
Impact:
This change resolves the issue of the cart-checking logic being incorrectly triggered when navigating to the cart.
Users can now smoothly add items to the cart and go to the cart without interference between the two actions.
@rmehta
Screencast.from.02-05-25.04.33.19.PM.IST.webm