Quantity Restrictions 

The interaction between you and your valued customers in the ever-evolving commerce landscape shapes up business practices. The metadata-based Quantity Restrictions promise your control over subscription management. This approach bestows you with unparalleled precision, enabling you to finely tune and personalize how your customers can adjust product quantities. By leveraging the potency of metadata, you now have the tools to harmonize between granting flexibility and applying constraints seamlessly.

Chargebee allows you to set restrictions on the quantity of your plans/add-ons. You have the provision to enable/disable product-level quantity restrictions across all products through a single setting.

Learn more about meta configurations here.

Prerequisites 

Please note that the below settings needs to be enabled to have the provision to enable/disable product-level quantity restrictions be applied:

Navigate to Settings > Configure Chargebee > Checkout & Self-Serve Portal > Configuration > Checkout

  • Allow customers to edit quantity for plans:
  • Allow customers to change addon and charge quantity

Enabling Quantity Restrictions 

Enabling this option allows Chargebee to read the configuration and set the quantity based on it.

Customize plan/addon quantity based on meta configuration on your Chargebee site:

Navigate to Settings > Configure Chargebee > Checkout & Self-Serve Portal > Advanced settings > Enable Customize plan/addon quantity based on meta configuration.

Set up Metadata for your Item Price 

Once you have enabled Customize plan/addon quantity based on the meta configuration, follow these steps:

  1. Navigate to Product Catalog > Plans.

  2. Select the corresponding Item price.The JSON Metadata set at Item price level will be considered and not at the item level.

  3. Click Add for JSON Metadata.

  4. On Add JSON Metadata page, add the necessary code to restrict the quantity.

  5. Click Add once done.

Configure the Checkout to Allow only Specific Quantity 

To configure the checkout to allow only specific quantity, you have to enter the values you wish you be allowed in Checkout and type as fixed.

Here is the sample JSON format that needs to be added.

Sample Code:

{ 
  "quantity_meta": {
    "type": "fixed",
    "values": [5, 6, 7, 8, 9, 10]
  }
}

Sample Checkout Screen

Configuring Limited Quantity Range in Checkout 

To allow a quantity that is limited to a particular range in your Checkouy, you have to provide the min(minimum), max(maximum), and step values along with the type as range.

Here is the sample JSON format that needs to be added.

Sample Code:

 {
  "quantity_meta": {
    "type": "range",
    "min": 10,
    "max": 100,
    "step": 10
  }
}

Each time your customer increases the quantity, it will be automatically incremented by the step value configured in the JSON.

Enter a valid quantity meta and click on the Add button to save the metadata.

Note

min, max, step have to be of type Number.

Edit the Metadata 

To edit the metadata,

  1. Navigate to Product Catalog > Plans.

  2. Select the plan then the Item price and click on the ellipsis menu.

  3. Select the Edit option and make the necessary changes.

  4. Click Update, once done.

Once these quantity restrictions are added, you can open the Checkout for the corresponding item price to test your changes.

Changes in Checkout based on Quantity Meta 

The following metadata types are supported for the quantity restrictions:

  • Fixed
  • Range

Checkout changes based on the metadata type in the JSON for an item price. Let us see the changes in Checkout for each metadata type.

Changes in Checkout when Quantity Meta is of type fixed 

When the Quantity Meta is of type fixed, the Checkout process undergoes the following changes:

  • Quantity Restriction: You can restrict the quantities to a set of numbers listed in the checkout for selection.

  • Dropdown Display: The dropdown will be the list of valid quantity values configured in the JSON metadata within the product card's specific plan/addon/charge section.

  • Invalid Quantity Handling: When you create a hosted page with a quantity not present in the values array, the quantity will reset to the least or minimum value (not necessarily the first value).

  • Configuration Setting: These checks on quantity will occur when the "Customize plan/addon quantity based on meta" configuration setting is enabled.

Changes in Checkout when Quantity Meta is of type range 

When the Quantity Meta is of type range, the Checkout process is adjusted as follows:

  • Quantity Restriction: You can set the quantity directly from the Checkout page to restrict the quantities to a range of numbers.

  • Stepper Display: The quantity is displayed with a stepper, allowing customers to increment or decrement the quantity as needed.

  • Invalid Quantity Handling: The value will be reset to the minimum configured value within the defined range if an invalid quantity is passed via API or Plan URL,

  • Step Increment:Each time a customer increments or decrements the quantity via the stepper, it is increased or decreased by the step value you set.

  • Custom Error Display: If a customer enters an invalid value in the quantity text box, a custom error message will be displayed to guide them. The error message can be customized. Learn more about working with labels to add a custom error.

Sample Error Screens

Was this article helpful?
Loading…