# cart-quantity-validation Function

The cart-quantity-validation Checkout Function runs on Shopify's servers, monitoring updates to a customer's Cart. It's only purposes, are:

* Prevent the customer from updating the quantity of an item from directly within the cart. A customer needs to check availability for the quantity they want from the PRP Rental Widget on the product page. If we didn't prevent quantity updates, a customer could start with a quantity of 1 when looking at the rental availability calendar, then increase it to 10 once they arrive to the cart, essentially bypassing the availability calendar.
* Prevent the customer from removing a Security Deposit product from the cart, whilst the rental product it's connected to is still in the cart.

To enable either of the capabilities above, the Checkout Function must be enabled on your store.

## Enabling the cart-quantity-validation Checkout Function

1. Go to Shopify **Settings > Checkout.**<br>

   <div align="left"><figure><img src="https://234434261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmpQXZYRz6niON4PyVhfO%2Fuploads%2FTEDZX9tUPPA0iVaZGzzP%2Fimage.png?alt=media&#x26;token=1efbe4cc-a34e-4205-852a-a4965a335eda" alt=""><figcaption></figcaption></figure></div>

   &#x20;
2. Scroll down to the bottom and look for the box named **Checkout rules.** Click **Add Rule**.\
   &#x20;
3. A popup will appear with a list of available checkout rules on your store. Click on **cart-quantity-validation** under **PRODUCT RENTALS PRO.**

   <div align="left"><figure><img src="https://234434261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmpQXZYRz6niON4PyVhfO%2Fuploads%2F7BaecVEIj4pjKHYyJcIc%2Fimage.png?alt=media&#x26;token=ac6c1825-0a78-417a-bf28-fd1646203b71" alt=""><figcaption></figcaption></figure></div>

   &#x20;
4. The rule screen will first ask you to save settings. Leave "allow all customers to complete checkout" ticked and click **Save**. The checkout rule is added.\
   &#x20;
5. Even though the checkout rule has been added, it is not turned on by default. Click **Turn on** at the top right of screen.

   <div align="left"><figure><img src="https://234434261-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmpQXZYRz6niON4PyVhfO%2Fuploads%2Fzbxhh9gqaZGartIUyWS6%2Fimage.png?alt=media&#x26;token=fffe7763-4d3b-4111-a40b-06604acac905" alt=""><figcaption></figcaption></figure></div>

   &#x20;
6. The **On** badge appears next to the title, meaning the Checkout Function is active, and the setup is complete!
