Jump to content

Restricting the amount of items a customer can order

Recommended Posts

Site URL: https://www.crusetdecouvertes.fr

Hello, i'm setting up an eshop for natural wine in France. As we are proposing very special wine from small producers with small production , we want to limit the quantity that one client can order, to avoid someone to take all the bottles in one command, and allow more customers to experience this wine. I check in eshop options and can just lowered the stock amount which doesn't reach my needs. Do you have any solution for that ? thanks in advance

Link to comment

Someone familiar with JavaScript could write some custom code to enforce a maximum order quantity on the product page and/or in the cart, but the benefit of this will be lost at the checkout stage because you cannot continue to enforce the limit on that page.

This is because Squarespace allow customers to edit the quantity on the checkout page (see yellow box on screenshot), and we are prevented from adding code to the checkout page to stop them doing this.

cart-quantity-limit.thumb.png.6650353a4635e70ec9788d6cf1b4938e.png

 

checkout-change-quantity.png.630ccd59ede8fa210194b70c639e5013.png

 

 

Edited by paul2009

About me: I'm Paul, a SQSP user for over 18 yrs and a Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL, providing 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 below. Buying a coffee is optional.

Book paid help with domains: Connect a GoDaddy domain. Connect a Squarespace Domain. Domain assistance

Link to comment
  • 3 weeks later...

You can do this using JavaScript. Insert the below code using code injection within the product page. As @Paul2009 said, this won't prevent people from adding the max amount multiple times, or changing the number in the shopping cart, but it prevents people from adding more than the max via the product page's add-to-cart function. 

Product page > Additional info > Code injection > [insert below] > Save

<script>
  document.querySelectorAll("input")[0].setAttribute("max", "#"); 
</script>

Change "#" to whatever number to be.  For example, if you don't want customers to be able to buy more than 3, your code would be:

<script>
  document.querySelectorAll("input")[0].setAttribute("max", "3"); 
</script>

Hope this helps!

 

Link to comment
  • 9 months later...

Site URL: https://terrazzo.nz/fibonacci-stone-terrazzo

Hi all,

I'm trying to limit the number of sample products customers can order from a page on our site. (NOTE: 'Add to Cart' has been altered to say "+ Add Sample")

Due to layout requirements, this is a standard page with each sample/product added as individual product blocks.

We want to limit the number of free samples that people can order to 3. Is there a way to do this? I have seen the code below but it isn't quite right for our page:

<script>
  document.querySelectorAll("input")[0].setAttribute("max", "3"); 
</script>

 

Our template:

Version 7.0– Brine family (Mojave template)

 

Thanks

Link to comment
  • 2 weeks later...

The short answer is no.

although you could technically do this on the product page, you will not be able to limit the overall quantity of products when customers reach the checkout page.

Edited by paul2009

About me: I'm Paul, a SQSP user for over 18 yrs and a Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL, providing 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 below. Buying a coffee is optional.

Book paid help with domains: Connect a GoDaddy domain. Connect a Squarespace Domain. Domain assistance

Link to comment

Thanks for the response... been looking further into this, does it make a difference that we are not bothered if someone manually changes the volume of each item in the checkout cart? They are free items so would just get sent one anyway.

What we need is a way to limit the different products added to the cart to 4...

Link to comment

I don't think this is possible. Some things you can do:

(a) use the announcement bar and mention customers can order a maximum of 4 free product samples at a time. I'm assuming you at least charge for shipping.

(b) include in each product description a note that customers can order only 4 free product samples at a time.

(c) in the Additional Information section during checkout, mention that only up to 4 product samples can be ordered at a time. Ask them to remove any other product samples over the limit.

(d) customize the confirmation email your customers receive to repeat the info: only 4 free products per order. If, after making it obvious on your site/store the 4-free-product-limit-per-order customers still put in more than 4 in their cart and check out, you can put in the confirmation email that only the first 4 free product samples will be sent to them.

There really is no way to set limits to the number of products customers are allowed to add to their carts, especially when it comes to free product samples.

Edited by sruss76
Link to comment
1 hour ago, fin1570048093 said:

Thanks for the response... been looking further into this, does it make a difference that we are not bothered if someone manually changes the volume of each item in the checkout cart?

Hi @fin1570048093

There are ways to achieve this with custom code, but the feasibility will depend on your site's template and the way it's been set up.  If you can provide me with a link to the site, I'll take a look and gain some context. For example, do you want to allow customers to select add just '1' of up to 4 samples, or 2 of two samples?

If the site isn't live, you'll also want to set a password in the visibility settings and share it with us. Without this, we won't be able to view the site.

Edited by paul2009

About me: I'm Paul, a SQSP user for over 18 yrs and a Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL, providing 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 below. Buying a coffee is optional.

Book paid help with domains: Connect a GoDaddy domain. Connect a Squarespace Domain. Domain assistance

Link to comment
  • 5 months later...

Hello @HarmlessStudio, I am trying to achieve something similar to @Crusetdecouvertes

I would like to limit my customers to 7 cart items. I do not mind if they can change this in the checkout but I would like it to be restricted whilst they are building their cart. I tried adding the code you suggested above, however it did not work to limit the cart to 7. Maybe it has to do with the updates Squarespace has made since you made this post. 

Do you have any suggestions? Thank you in advance. 

Link to comment
  • 1 year later...
  • 9 months later...
On 1/13/2023 at 6:44 AM, rasmusarentsen said:

<script> document.addEventListener('DOMContentLoaded', () => { var qty = document.querySelector('input[type="number"]'); qty.setAttribute('max', '5'); }); </script>

I have tried this code but does not seem to make any difference.   Am using Brine 7.0 if that matters.

I understand the user can change in the final checkout section  ; and am ok with that I just want to limit the quantity of an item allowed in a cart.  

Do I insert the code under the product page, additional info, javascript?  

I tried that as well as Page Header Code Injection for the store page but neither seemed to do anything.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.