RuffRuff Order Limits

thumbnail

(Example) Set a wholesale-only minimum purchase weight using a customer metafield

An example that uses a customer metafield to separate large and regular wholesale customers, sets a minimum purchase weight per order for each group, and blocks everyone else from purchasing.

This example uses a customer type stored in a customer metafield to let large wholesale customers purchase with a cart total of 50kg or more and regular wholesale customers with 20kg or more. Everyone else, including guests, cannot purchase, so it suits a wholesale-only store.

Use the Full plan and prepare customer accounts for testing. This example evaluates the entire cart in a single order, so customers other than wholesale customers cannot purchase any item. To target only specific items, set "Applicability" and "Eligible items."

Weight is evaluated on the total of the weight registered on each eligible item in the cart, multiplied by its quantity.

Customer

Customer type value and login status

Cart total they can purchase with

Large wholesale

wholesale_large and logged in

50kg or more

Regular wholesale

wholesale and logged in (no wholesale_large)

20kg or more

Other members

Any other value or no value, and logged in

Cannot purchase

Guest

Not logged in

Cannot purchase

(1) Add a definition

In the Shopify admin, open a customer. Under Metafields, select "Add definition," then create and save the following customer metafield.

Setting

Example

Name

Customer type

Namespace and key

custom.customer_type

Type

Single line text (single value)

Shopify Help: Creating custom metafield definitions

(2) Add a value for each customer

Enter wholesale_large in "Customer type" for large wholesale customers and wholesale for regular wholesale customers, then save. After saving, confirm each customer's value.

Shopify Help: Adding values to metafields

(1) Create a rule

In the app admin, go to "Weight limits" → "Weight rules by customer group" → "Create rule," then enter "Wholesale minimum purchase weight" as the rule name.

(2) Specify the metafield to use

Under "Group condition," select "Customer metafield," enter custom for the namespace, and enter customer_type for the key. A rule can use only this one combination of namespace and key.

(3) Add the additional groups

Select "Add group" and add the following two groups. Arrange the additional groups with Large wholesale first and Regular wholesale second.

Group name

Metafield value

Large wholesale

wholesale_large

Regular wholesale

wholesale

Metafield values are matched exactly. Differences in capitalization or leading or trailing spaces prevent a match. Even if a customer type is set, the Guest limits apply when the customer is not logged in.

(4) Set the limit for each group

Set Large wholesale and Regular wholesale to "Limit" and enter only the minimum weight. Leave the maximum weight blank. Set "Member" and "Guest" to "Cannot purchase." A group set to "Cannot purchase" does not need a minimum or maximum weight.

Group

Limit

Minimum weight

Maximum weight

Large wholesale

Limit

50

Blank

Regular wholesale

Limit

20

Blank

Member

Cannot purchase

Not required

Not required

Guest

Cannot purchase

Not required

Not required

(5) Set the weight unit and how totals are calculated

Under "Weight unit," select "Kilograms (kg)," and under "When product weight unit differs," select "Convert and include in calculation." Select "Cart" for "Applicability" and "All products" for "Eligible items."

  • Products registered in grams are converted to kilograms and totaled when you select "Convert and include in calculation." "Exclude from calculation" leaves them out of the total, which makes the minimum purchase weight impossible to meet.

  • A variant with no weight registered is totaled as 0. When you set a minimum purchase weight, check that the eligible products have a weight registered.

(6) Set the messages and enable the rule

Set the following messages, check "Display timing," save the settings, then select "Enable" on the details page.

Setting

Example

Message for the minimum weight

{{tierName}} customers must have a cart total of {{minWeight}} or more.

Message for a blocked group

{{tierName}} customers cannot purchase.

{{minWeight}} is replaced with the unit included, such as 50kg. Do not add the unit again in the message.

With no other rules affecting the result, confirm the following. This setting does not change the quantity field on the product page. Check the result in the cart or at checkout.

Customer to test

Cart total

Result of this rule

Large wholesale

50kg / 49.9kg

Meets the limit / Below the minimum weight

Regular wholesale

20kg / 19.9kg

Meets the limit / Below the minimum weight

A member whose customer type is empty or a different value

Any

Cannot purchase as Member

Not logged in

Any

Cannot purchase as Guest

A member whose customer type is Wholesale (capitalized)

Any

Cannot purchase as Member

Check in the cart when "Display timing" is "Cart updated and checkout," or at checkout when it is "Checkout only." Even if this rule's condition is met, the customer cannot purchase when another rule is violated.