Quantity rules
Applies toShopifyBigCommerceWooCommerceMagento
Set a pack size
A pack size means a product must be ordered in multiples of a number, for example 6, 12, 18. With a pack size of 6, the quantity selector moves in steps of 6. It's also called a quantity increment.
-
Turn on the pack size field (once). In SparkLayer, go to Integrations,Platform (opens in your SparkLayer Dashboard in a new tab) and, in the Metafields card, click Configure next to SparkLayer metafields. Make sure B2B - Pack Size is enabled. SparkLayer adds the field to your Shopify variants.
More detail
See Shopify metafields and data mapping. To create the field yourself instead, go to Settings,Custom data,Variants (opens in your Shopify admin in a new tab) in the Shopify admin and add a definition:
Field Value Name Any name, for example B2B - Pack SizeNamespace and key sparklayer.pack_sizeType Integer, One value -
Enter the pack size. Open the product in the Shopify admin, select a variant and enter the pack size in the B2B - Pack Size field, for example
6. -
Save the product.
-
Check it. Sign in to your store as a B2B customer and open the product. The quantity selector moves in steps of 6, and a Qty rules apply link under it says "This product comes in pack sizes of 6".
Lots of products? Fill them in one tableShopify
In your Shopify admin, go to Products, tick the products and click Edit products. Click Columns, tick B2B - Pack Size under Metafields, then type the values (each variant has its own row) and click Save. Shopify's guide
Common mistake: wrong namespace
If you create the field yourself, its Namespace and key must read exactly sparklayer.pack_size. Shopify fills in custom. for you, and SparkLayer never reads that. See Add metafields by hand.
-
Add the field. Add a variant-level product field with the values below. See your platform's guide for where to add it: BigCommerce, WooCommerce or Magento.
Field Value Custom data type Variant-level (products) Metafield type integerNamespace sparklayerKey pack_sizeValue A whole number, for example 6 -
Turn it on in SparkLayer. Go to Integrations,Platform (opens in your SparkLayer Dashboard in a new tab) and, in the Metafields card, click Configure next to SparkLayer metafields, then enable the pack size. SparkLayer doesn't read a field until it's enabled, even if it already exists in your store.
-
Check it. Sign in to your store as a B2B customer and open the product. The quantity selector moves in steps of your pack size.
For more detail, see the developer docs.
Every quantity rule is set on the product variant, even when the product has a single variant. To give all of a product's variants the same rule, enter it on each one, or use the bulk editor.
Set minimum and maximum quantities
Minimum and maximum quantities stop customers ordering too few or too many units. Each one has its own field, and they work the same way as the pack size:
| Rule | What it does | Field (metafield key) |
|---|---|---|
| Minimum per variant | Each variant (for example each colour) must be ordered in at least this quantity. | min_order_quantity |
| Maximum per variant | Each variant can be ordered in at most this quantity. | max_order_quantity |
| Minimum per product | The total across all of a product's variants must be at least this quantity. | min_order_parent_quantity |
| Maximum per product | The total across all of a product's variants can be at most this quantity. | max_order_parent_quantity |
- Turn on the field for your rule. On Shopify, go to Integrations,Platform (opens in your SparkLayer Dashboard in a new tab) and, in the Metafields card, click Configure next to SparkLayer metafields. On other platforms, add it first using the metafield reference, then enable it there.
- On each variant, enter a whole number, for example
6,12or20. Product-wide rules are still entered on each variant. - Save the product.
Lots of products? Fill them in one tableShopify
In your Shopify admin, go to Products, tick the products and click Edit products. Click Columns, tick the SparkLayer field under Metafields, then type the values (each variant has its own row) and click Save. Shopify's guide
BigCommerce only
On BigCommerce, you can also use BigCommerce's own Minimum and Maximum Order Quantity (opens in a new tab) product setting. SparkLayer applies it to each variant, so each variant gets its own minimum or maximum, even though BigCommerce sets it on the product.
What customers see
When a product has a quantity rule, the product interfaces apply it as customers build their order:
- The quantity selector follows the rule. If a customer types a quantity that doesn't fit the pack size, it updates to fit.
- A Qty rules apply link appears under the quantity selector. It opens the rule, such as "This product comes in pack sizes of 6".
- With a pack size, a pack price shows under the unit price, for example Pack (6): US$71.40.
Show or hide the pack price
The pack price is the unit price multiplied by the number of items in a pack. It shows in the product detail interface.
To hide the pack price, you or your developer add this line to your custom CSS:
--spark-pdp-pack-size: none;To change the pack price wording without code, add a translation override for the key pdp.price.pack-size at Storefront,Options,Translation overrides (opens in your SparkLayer Dashboard in a new tab). In the text, {packSize} is the pack size and {price} the pack price.
For developers: set the text in the Core Script
Set it in your Core Script instead (see Languages and international):
translations: {
en: {
"pdp.price.pack-size": "Pack ({packSize}): {price}",
}
},<!-- SparkLayer Core Script: in your theme, just before </head>.
Already have window.sparkOptions? Add just the setting to it. -->
<script>
window.sparkOptions = {
translations: {
en: {
"pdp.price.pack-size": "Pack ({packSize}): {price}",
}
},
};
</script>Hide the "Qty rules apply" message
To hide the link, you or your developer add this line to your custom CSS:
--spark-product-qty-rules-display: none;Set order limits
Order limits apply to the whole order rather than to one product, and customers can't check out until their order meets them. They're rules on a customer group, so they don't need metafields. There are two:
| Rule | What it limits | Example |
|---|---|---|
| Order total limits | The order total: a minimum and, if you want one, a maximum, per currency. | The order must be at least $250. |
| Order quantity limits | The number of items in the order: a minimum or a maximum. | The order must have at least 12 items. |
To set them:
- Go to Customers,Groups (opens in your SparkLayer Dashboard in a new tab) and click a group's name (or Edit on the base customer group, for every group).
- Under Inherited rules, click + Override next to Order total limits or Order quantity limits (on the base group, + Customize).
- For Order total limits, choose a Currency and enter a Minimum order total and, if you want one, a Maximum (optional). To set a limit in another currency, click Add order total limit. To remove one, click the bin icon next to it. For Order quantity limits, click Configure.
- Click Save.
More detail
- Order totals are net, which means they exclude tax. With tax-inclusive price display on, they're checked against the gross total the customer sees instead.
- You can also enter a minimum order value when you create a customer group. It becomes the group's Order total limits rule.
- Groups follow the base customer group's limits until you override them. Click Reset on the rule to hand it back.
- For a minimum, maximum or pack size on one product, use the product quantity rules above instead.
When a customer's order doesn't meet a limit, the My Cart shows a message such as "Your order must be more than $100 to meet the order requirements" and Checkout is unavailable until they change their order.
Change the order limit messages
To change the wording without code, add a translation override for the message's key, shown below, at Storefront,Options,Translation overrides (opens in your SparkLayer Dashboard in a new tab). See Languages and international. In the text, {amount} is the order total limit, and {minimum} and {maximum} the number of items.
For developers: set the text in the Core Script
For order total limits:
translations: {
en: {
"cart.validation-message.minimum-order-totals": "Your order must be more than {amount} to meet the order requirements.",
"cart.validation-message.maximum-order-totals": "Your order must be less than {amount} to meet the order requirements.",
}
},<!-- SparkLayer Core Script: in your theme, just before </head>.
Already have window.sparkOptions? Add just the setting to it. -->
<script>
window.sparkOptions = {
translations: {
en: {
"cart.validation-message.minimum-order-totals": "Your order must be more than {amount} to meet the order requirements.",
"cart.validation-message.maximum-order-totals": "Your order must be less than {amount} to meet the order requirements.",
}
},
};
</script>For order quantity limits:
translations: {
en: {
"cart.validation-message.minimum-order-item-quantity": "Your order must have at least {minimum} items to meet the order requirements.",
"cart.validation-message.maximum-order-item-quantity": "Your order must not exceed {maximum} items to meet the order requirements.",
}
},<!-- SparkLayer Core Script: in your theme, just before </head>.
Already have window.sparkOptions? Add just the setting to it. -->
<script>
window.sparkOptions = {
translations: {
en: {
"cart.validation-message.minimum-order-item-quantity": "Your order must have at least {minimum} items to meet the order requirements.",
"cart.validation-message.maximum-order-item-quantity": "Your order must not exceed {maximum} items to meet the order requirements.",
}
},
};
</script>Quantity pricing (tiered pricing)
Quantity pricing gives lower unit prices for larger quantities, for example buy 1 for $10 or 10 for $8. See Quantity pricing and settings.
Quantity pricing sets a minimum too: the lowest quantity tier in the customer's price list is the smallest quantity they can order. If a product's first tier is 50+, customers see "Unavailable in selected quantity" below 50. To let them order fewer, add a price from a quantity of 1.
Unit of measure pricing
Unit of measure pricing sets prices for units such as boxes, cartons or pallets. See unit of measure pricing.
Set different rules for each customer group
Everything above applies to all your B2B customers. To give a customer group its own pack size, minimum or maximum, use the sparklayer.settings field on the variant (product settings). For example, most customers could buy in packs of 6 and a tier-2 group in packs of 12.
- Find each group's handle: open the group at Customers,Groups (opens in your SparkLayer Dashboard in a new tab) and look under Handle (or ID).
- In the form below, enter each group's handle and its rules. It writes the value for you. Use
basefor the rules everyone else gets. - Click Copy, paste the value into the variant's
sparklayer.settingsfield and save. To give many variants the same rules, paste it into each row in Shopify's bulk editor.
sparklayer.settingsField details, if you add the field by hand
| Field | Value |
|---|---|
| Custom data type | Variants (Shopify (opens in a new tab)), or variant-level product fields on other platforms |
| Metafield type | JSON |
| Namespace | sparklayer |
| Key | settings |
| Value | One entry per customer group, for example [{"customer_group":"base","pack_size":6},{"customer_group":"tier-2","pack_size":12}] |
See Product rules per customer group for everything this field can do.
Once a variant has settings, its other quantity fields are ignored
If a variant has any sparklayer.settings value, even one that only hides it from a group, SparkLayer ignores its individual fields such as sparklayer.pack_size. Put the pack size, minimum and maximum inside the JSON instead.
Which rule wins
SparkLayer uses the first of these that applies to the customer:
- The customer's group entry in
sparklayer.settings. It overrides thebaseentry for that group. - The
baseentry insparklayer.settings. It's the default for every customer group. - The individual fields, such as
sparklayer.pack_sizeandsparklayer.max_order_quantity, but only when the variant has nosparklayer.settingsvalue.
For example:
[
{ "customer_group": "base", "pack_size": 50 },
{ "customer_group": "retail-partners", "pack_size": 10, "display": true },
{ "customer_group": "distributors", "display": false }
]Every group buys in packs of 50, except retail-partners, who buy in packs of 10. distributors don't see the product. A sparklayer.pack_size on the same variant is ignored. See Product rules per customer group.
Metafield reference
This reference is for whoever sets up your product data. All keys use the namespace sparklayer and are set on product variants. On Shopify, the custom data type is Variants (opens in a new tab). On other platforms, use variant-level product fields.
| Key | Type | Value |
|---|---|---|
pack_size | integer | A whole number, for example 6 |
min_order_quantity | integer | A whole number, for example 6, 12 or 20 |
min_order_parent_quantity | integer | A whole number, for example 6, 12 or 20 |
max_order_quantity | integer | A whole number, for example 6, 12 or 20 |
max_order_parent_quantity | integer | A whole number, for example 6, 12 or 20 |
settings | JSON | One entry per customer group. See Product rules per customer group. |
Troubleshooting
FAQs
The quantity updates to fit the pack size. Products added with a 1-click ordering button are rounded up to the next full pack.
Yes. Spark Buttons add a set of SKUs and quantities to an order in one click. See 1-click ordering buttons.
Yes. The messages are translations such as global.product-settings.pack-size and min-order-quantity. See Change text that contains variables.
Last updated