Skip to content

Quantity rules

Applies toShopifyBigCommerceWooCommerceMagento

Steps for

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.

  1. 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:

    FieldValue
    NameAny name, for example B2B - Pack Size
    Namespace and keysparklayer.pack_size
    TypeInteger, One value
  2. 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.

  3. Save the product.

  4. 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.

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:

RuleWhat it doesField (metafield key)
Minimum per variantEach variant (for example each colour) must be ordered in at least this quantity.min_order_quantity
Maximum per variantEach variant can be ordered in at most this quantity.max_order_quantity
Minimum per productThe total across all of a product's variants must be at least this quantity.min_order_parent_quantity
Maximum per productThe total across all of a product's variants can be at most this quantity.max_order_parent_quantity
  1. 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.
  2. On each variant, enter a whole number, for example 6, 12 or 20. Product-wide rules are still entered on each variant.
  3. 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):

Core Script
translations: {
  en: {
   "pdp.price.pack-size": "Pack ({packSize}): {price}",
  }
},

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:

RuleWhat it limitsExample
Order total limitsThe order total: a minimum and, if you want one, a maximum, per currency.The order must be at least $250.
Order quantity limitsThe number of items in the order: a minimum or a maximum.The order must have at least 12 items.

To set them:

  1. 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).
  2. Under Inherited rules, click + Override next to Order total limits or Order quantity limits (on the base group, + Customize).
  3. 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.
  4. 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:

Core Script
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.",
  }
},

For order quantity limits:

Core Script
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.",
  }
},

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.

  1. 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).
  2. In the form below, enter each group's handle and its rules. It writes the value for you. Use base for the rules everyone else gets.
  3. Click Copy, paste the value into the variant's sparklayer.settings field and save. To give many variants the same rules, paste it into each row in Shopify's bulk editor.
Build the value Fill in what you need and leave the rest blank.
Customer group 1
Paste into sparklayer.settings
Fill in a value above
Field details, if you add the field by hand
FieldValue
Custom data typeVariants (Shopify (opens in a new tab)), or variant-level product fields on other platforms
Metafield typeJSON
Namespacesparklayer
Keysettings
ValueOne 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:

  1. The customer's group entry in sparklayer.settings. It overrides the base entry for that group.
  2. The base entry in sparklayer.settings. It's the default for every customer group.
  3. The individual fields, such as sparklayer.pack_size and sparklayer.max_order_quantity, but only when the variant has no sparklayer.settings value.

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.

KeyTypeValue
pack_sizeintegerA whole number, for example 6
min_order_quantityintegerA whole number, for example 6, 12 or 20
min_order_parent_quantityintegerA whole number, for example 6, 12 or 20
max_order_quantityintegerA whole number, for example 6, 12 or 20
max_order_parent_quantityintegerA whole number, for example 6, 12 or 20
settingsJSONOne entry per customer group. See Product rules per customer group.

Troubleshooting

FAQs

Was this page helpful?

Last updated