Guest41 Posted May 16, 2022 Share Posted May 16, 2022 I wanted to know if there was a way to limit the number of checkboxes a person can select. So, after a person clicks the add to cart, they are greeted with a form that has multiple checkboxes I wanted to know if there was a way to limit it. Link to comment
Guest41 Posted May 16, 2022 Author Share Posted May 16, 2022 (edited) 6 hours ago, Guest41 said: I wanted to know if there was a way to limit the number of checkboxes a person can select. So, after a person clicks the add to cart, they are greeted with a form that has multiple checkboxes I wanted to know if there was a way to limit it. Would something like this be possible within squarespace using jQuery or Javascript? Or if there are any possible plugins that may work? Edited May 16, 2022 by Guest41 Link to comment
paul2009 Posted May 17, 2022 Share Posted May 17, 2022 16 hours ago, Guest41 said: I wanted to know if there was a way to limit the number of checkboxes a person can select…after a person clicks the add to cart. It is possible but it is reasonably complex to achieve and so you’re unlikely to find an answer in a post. This is because Product Forms are not loaded with the page. The code will therefore require a mutation observer that loads on product detail pages and product blocks and looks for a Product Form to be added to the page. When a form has been added, the code needs to inspect the newly added form to see if it contains checkboxes. If it does, the code must look for checkboxes to be clicked. When clicked, the code will need to check if the checkbox is being checked or unchecked. If being checked, the code must count the checkboxes that are already checked to determine whether the limit has been reached. If it hasn’t, the box can be checked; if the limit has been reached, it should remain unchecked. The code will also need to do the same on the cart page where the user can also edit the product form. creedon 1 Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional. Would you like your customers to be able to mark their favourite products in your Squarespace store? Link to comment
Guest41 Posted May 18, 2022 Author Share Posted May 18, 2022 On 5/17/2022 at 2:30 AM, paul2009 said: It is possible but it is reasonably complex to achieve and so you’re unlikely to find an answer in a post. This is because Product Forms are not loaded with the page. The code will therefore require a mutation observer that loads on product detail pages and product blocks and looks for a Product Form to be added to the page. When a form has been added, the code needs to inspect the newly added form to see if it contains checkboxes. If it does, the code must look for checkboxes to be clicked. When clicked, the code will need to check if the checkbox is being checked or unchecked. If being checked, the code must count the checkboxes that are already checked to determine whether the limit has been reached. If it hasn’t, the box can be checked; if the limit has been reached, it should remain unchecked. The code will also need to do the same on the cart page where the user can also edit the product form. Do you have any way I can go about doing this? I have multiple products that need different maximum values and I'm pretty new to using code with applications such as squarespace so would I need to learn more about different languages such as jQuery and JavaScript or find a different solution all together? Link to comment
paul2009 Posted May 18, 2022 Share Posted May 18, 2022 1 hour ago, Guest41 said: Do you have any way I can go about doing this? This shows the checkbox limiting part but as I mentioned it will require a Squarespace specific wrapper that loads this every time the lightbox form appears. Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional. Would you like your customers to be able to mark their favourite products in your Squarespace store? Link to comment
Guest41 Posted May 18, 2022 Author Share Posted May 18, 2022 5 minutes ago, paul2009 said: This shows the checkbox limiting part but as I mentioned it will require a Squarespace specific wrapper that loads this every time the lightbox form appears. Would I need to use the lightbox form id in order to run a check for when it's pulled up like when it says .enabled. Link to comment
Guest41 Posted May 19, 2022 Author Share Posted May 19, 2022 4 hours ago, Guest41 said: Would I need to use the lightbox form id in order to run a check for when it's pulled up like when it says .enabled. What specific content wrapper do I need in order to see what content I need to check is enabled? Link to comment
creedon Posted May 19, 2022 Share Posted May 19, 2022 If you do not understand what a Mutation Observer is you need to contact a developer to determine if what you want to accomplish is doable. As @paul2009 mentions this is a complex issue that is unlikely to be solved in several posts. paul2009 1 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment