Liquid, JavaScript, themes, sales channels
This is a bit hard to explain.
I have a snippet that creates a checkbox form element with the property "required" (unless this checkbox is checked, form cannot be submitted). This snippet is called right above the checkout button on the cart.
The issue is with the cart notification popup - if I'm on the "/cart" page the snippet runs twice - once for the (hidden) cart notification popup and once for the cart page itself. In this case, if the user clicks "checkout", the checkboxes are BOTH validated. Of course, the hidden one is "unchecked", and so the form submission is halted.
I need a way to detect if the snippet has already run (if the form element has already been created) on the current page.
So:
If [snippet has NOT already run] AND [current page is /cart] THEN [don't include REQUIRED tag on the checkbox]
and
If [snippet has already run] AND [current page is /cart] THEN [include REQUIRED tag on the checkbox]
Did that make any sense? I'm having trouble explaining it.
Solved! Go to the solution
This is an accepted solution.
@nagumi hi,
You have to check the visibility of parent in which you adding the checkbox code.
Hope you got the logic...
This is an accepted solution.
@nagumi hi,
You have to check the visibility of parent in which you adding the checkbox code.
Hope you got the logic...
User | RANK |
---|---|
12 | |
10 | |
10 | |
7 | |
6 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022