Display quantity rules and volume pricing on your store
Quantity rules for B2B catalog are supported on free Shopify themes, version 8.0.0 or later, and volume pricing is supported on version 11.0.0 or later. If you want to display quantity rules and volume pricing on your store, then you can update your store's theme to the latest version.
If you don't want to change or update your theme, then you can add the following code to your theme to display quantity rules and volume pricing. Before you make updates to your theme files, ensure that you duplicate your theme to create a backup copy.
A product variant's cart quantity value can be displayed on the product page or featured product section. The value can be fetched by using Liquid.
Add Liquid product cart quantity code
You can add code to the following files in your theme to support cart quantity:
main-product.liquid or equivalent
featured-product.liquid or equivalent
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the file that you want to edit.
Create a new line at the bottom of the file, and add the following code:
Click Save.
Add Javascript cart quantity code
When a variant's cart quantity changes, the value displayed on the product page or featured product section must be updated. The updated value can be fetched by using Javascript code.
You can add code to the theme.js file or equivalent.
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the theme.js file.
Create a new line at the bottom of the file, and add the following code:
Click Save.
Quantity rules
A product variant's quantity rules can be displayed on the product page or featured product section. The rules can be fetched by using Liquid.
Add Liquid quantity rules code
You can add code to the following files in your theme to support quantity rules:
main-product.liquid or equivalent
featured-product.liquid or equivalent
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the file that you want to edit.
Create a new line at the bottom of the file, and then add the following code:
Click Save.
Add Javascript quantity rules code
Each variant of a product can have its own set of quantity rules. After a different variant is selected, the quantity rules displayed on a product page or featured product section need to be updated. The updated value can be fetched using Javascript code.
theme.js or equivalent
en.default.json
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the theme.js file.
Create a new line at the bottom of the file, and then add the following code:
Click Save.
Volume pricing
Add Liquid volume pricing code
You can add code to the following files in your theme to display volume pricing:
main-product.liquid or equivalent
featured-product.liquid or equivalent
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the file that you want to edit.
Create a new line at the bottom of the file, and then add the following code:
Click Save.
Add Javascript volume pricing code
You can add code to the following file in your theme to display volume pricing:
theme.js
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the theme.js file.
Create a new line at the bottom of the file, and then add the following code:
Click Save.
Add locales
To ensure that quantity rules and volume pricing displays on all translated versions of your online store, you can add locales by adding the following JSON translation strings to your en.default.json file.
Steps:
From your Shopify admin, go to Online Store > Themes.
Find the theme that you want to edit, click the ... button to open the actions menu, and then click Edit code.
Open the en.default.json file.
Create a new line at the bottom of the file, and then add the following code:
Click Save.
Can’t find the answers you’re looking for? We’re here to help.