-
-
Couldn't load subscription status.
- Fork 63
Fix conflict with the YesCookie plugin #245
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughTwo event handlers in the checkout module now include conditional checks to prevent assigning Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
assets/js/checkout.js(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cypress (8.2, chrome)
- GitHub Check: cypress (8.1, chrome)
🔇 Additional comments (1)
assets/js/checkout.js (1)
18-22: Good defensive check to prevent invalid template_id assignment.The expanded conditional ensures that
checkout.template_idis only set when a valid, truthy value exists indata.order.extra.template_id. This prevents corruption from undefined or empty values that might arise from cookie consent plugins interfering with data flow.
| wu_listen_to_cookie_change('wu_template', function (value) { | ||
|
|
||
| checkout.template_id = value; | ||
|
|
||
| if (value) { | ||
| checkout.template_id = value; | ||
| } | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Proper safeguard against cookie clearing by consent plugins.
The truthy check prevents the template_id from being overwritten when the wu_template cookie is cleared or set to an empty value, which can happen when cookie consent plugins like YesCookie modify cookies. This ensures the checkout state remains consistent.
Please confirm that this resolves the YesCookie plugin conflict by testing the checkout flow with the YesCookie plugin active, particularly:
- Initial page load with cookie consent banner
- Accepting/rejecting cookies
- Navigating through checkout steps
You can verify the template_id remains stable by checking the Vue instance state:
🏁 Script executed:
#!/bin/bash
# Search for any other cookie-related template_id assignments that might need similar guards
rg -n -C3 'template_id\s*=' --type=js -g '!node_modules' -g '!dist' -g '!build'Length of output: 14111
Apply same cookie clearing guard to assets/js/template-switching.js for consistency.
The PR correctly adds a truthy check in checkout.js line 72, but assets/js/template-switching.js line 19 contains an identical cookie listener pattern without the same protection. Both listen to the wu_template cookie and both assign to template_id. This inconsistency means the YesCookie plugin conflict is only partially resolved.
Update assets/js/template-switching.js line 17-21:
wu_listen_to_cookie_change('wu_template', function(value) {
if (value) {
window.wu_template_switching.template_id = value;
}
});🤖 Prompt for AI Agents
In assets/js/template-switching.js around lines 17 to 21, the cookie listener
assigns wu_template directly to window.wu_template_switching.template_id without
a truthy guard; update the listener to check if value is truthy before assigning
(i.e., wrap the assignment in if (value) {
window.wu_template_switching.template_id = value; }) so it matches the guard
added in assets/js/checkout.js and avoids YesCookie plugin conflicts.
Summary by CodeRabbit