Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: vtex discount coming negative #138

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

bruno-monteiro1
Copy link
Contributor

This PR addresses the issue of discount values coming as a negative number, while some parts of the code expect them to be positive.

One of the side effects of this issue is the wrong display of the total value in Minicart and the abscence of the discounts component inside it.

@guitavano
Copy link
Contributor

I think it impacts de events triggereds, for example at "add_to_cart", google does not expect negative "discount".
https://developers.google.com/analytics/devguides/collection/ga4/reference/events?sjid=14806687593381695830-SA&hl=pt-br&client_type=gtag#add_to_cart

can you check? and maybe fix?

@bruno-monteiro1
Copy link
Contributor Author

bruno-monteiro1 commented Feb 8, 2024

I found 6 instances of sendEvent usage.

The ones where the discount parameter is calculated by this code are already fixed because they end up receiving the converted value of this PR.

The others use the itemToAnalyticsItem of the useCart hook, which already returns the correct value for the discount because it subtracts the sellingPrice from the listPrice of the object, always ending up in a positive value.

@guitavano guitavano merged commit 0db8398 into deco-sites:main Feb 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants