Cart-based Data Source rules evaluate what is currently in the shopper's cart and surface products based on cart contents, cart value, item counts, or applied discount codes. These rules only work on cart-based widgets. From the Rebuy widget types, those are Cart, Shopify Checkout, Recharge Checkout, Shopify Thank You, Recharge Thank You, Post Purchase, and Global widgets. A Product Page widget cannot use cart rules, because it only has access to the product currently being viewed, not the cart object.
The cart-based IF rules covered in this article:
For the full Data Source rules reference covering every IF and RETURN type, see Data Sources 101.
IF Cart Rule
The Cart rule targets the rule based on the products currently in the shopper's cart. Use it to fire a rule when specific products are present, when a subscription is in the cart, or when certain products are absent.
Operators: Contains All, Contains Subscription, Does Not Contain Any.
Value: one or more products selected from the Shopify catalog. The Contains Subscription operator takes no product value.
Contains All: fires only when every selected product is present in the cart.
Contains Subscription: fires whenever any cart line item has a subscription selling plan attached. No product selection is needed.
Does Not Contain Any: fires only when none of the selected products are in the cart.
IF Cart Contains ALL
The Contains All operator fires only when every product selected on the rule is present in the cart. If you select two products, both must be in the cart for the rule to fire. A cart holding only one of them does not qualify.
IF Cart Contains All → [Product A] + [Product B]
RETURN Specific Product → [Gift Product]
This rule returns a gift product only when both Product A and Product B are in the cart.
Contains All with a Quantity Condition
Add a quantity condition to a Contains All rule to require a minimum, maximum, or exact number of the selected product before the rule fires. The quantity is measured against the matched product's total units in the cart.
Operators: Is Greater Than, Is Less Than, Equals.
Example:
IF Cart Contains All → [Product A] Quantity Is Greater Than → 1
RETURN Specific Product → [Gift Product]
This rule fires only when Product A is in the cart with a quantity greater than 1, then returns the gift product.
Contains All Combined with Contains Subscription
Combine a Contains All rule with AND Contains Subscription condition to target shoppers who have a specific product in the cart and are also subscribing. Both conditions must be true for the rule to fire.
Example:
IF Cart Contains All → [Product(s)]
AND Cart Contains Subscription
RETURN Specific Product → [Subscriber-Only Gift]
IF Cart Contains Subscription
The Contains Subscription operator fires whenever any line item in the cart has a subscription selling plan attached. It takes no product value, so it matches on the presence of a subscription rather than on a specific product.
Tip: This rule can also be used to suppress the widget whenever the cart holds a subscription item.
Example: This rule returns no products, which hides the widget, whenever the cart contains a subscription item.
IF Cart Contains Subscription
RETURN No Products
IF Cart Does Not Contain Any
The Does Not Contain Any operator fires only when none of the selected products are in the cart. As soon as any one of the selected products is added, the rule stops firing.
Example:
IF Cart Does Not Contain Any → [Product A] + [Product B]
RETURN Endpoint → Recommended (AI)
This rule surfaces recommendations only while neither Product A nor Product B is in the cart, so the widget stops showing once the shopper adds either product.
IF Cart Subtotal Rule
The Cart Subtotal rule targets the rule based on the total subtotal value of the cart. It is most often paired with a Gift With Purchase widget where the shopper has to spend a threshold amount to unlock a free gift, but the same logic applies to any cart-based widget.
Operators: Is Greater Than, Is Less Than, Is Equal To.
Value: a dollar amount.
Is Greater Than fires when the cart subtotal is greater than the entered amount.
Is Less Than fires when the cart subtotal is less than the entered amount.
Is Equal To fires when the cart subtotal is exactly equal to the entered amount.
IF Cart Subtotal Is Greater Than
IF Cart Subtotal Is Greater Than → $99.99
RETURN Specific Product → [Free Gift Product]
This rule returns the gift product only when the cart subtotal is greater than $99.99 This is the standard setup for a Gift With Purchase where the shopper has to spend a minimum to receive the free gift.
IF Cart Subtotal Is Less Than
IF Cart Subtotal Is Less Than → $99.00
RETURN Endpoint → Recommended (AI)
This rule surfaces recommendations only when the cart subtotal is less than $99. This is useful at checkout when you want to avoid showing expensive products that need more consideration before a shopper adds them.
Combining IF Cart Subtotal Is Greater Than AND Is Less Than
IF Cart Subtotal Is Greater Than → $49
AND Cart Subtotal Is Less Than → $99
RETURN Specific Product → [Add-On Product]
This rule fires only when the cart subtotal is between $49 and $99. It is helpful when you have a free shipping threshold and want to push the shopper to spend enough to qualify. This setup is commonly paired with a Smart Cart Cart Flyout widget when the free shipping bar is active.
Add Condition: Scope Cart Subtotal by Tag or Collection
Click Add Condition on the Cart Subtotal rule to measure spend on a subset of cart items instead of the whole cart. Two scoping options are available.
With Tag: sums only the items whose product carries the specified Shopify product tag.
From Collection: sums only the items whose product belongs to the specified Shopify collection.
The Cart Subtotal rule accepts one scoping condition at a time. You cannot stack a tag and a collection condition on the same Cart Subtotal rule.
Note: When a tag or collection condition is added, Rebuy calculates the scoped subtotal from each item's product price multiplied by quantity. This calculated amount can differ from the subtotal Shopify displays when cart, shipping, or line-item discounts are applied, because those adjustments are not factored into the scoped calculation.
IF Cart Subtotal With Tag
IF Cart Subtotal Is Greater Than → $50.00 With Tag → "apparel"
RETURN Specific Product → [Free Gift Product]
This rule fires only when the combined price of cart items tagged apparel is greater than $50.00. Items without the apparel tag are ignored in the calculation, so a cart holding $40.00 of apparel and $30.00 of accessories does not qualify, even though the full cart total is $70.00.
(Image example above: Cart Subtotal rule With Tag condition)
IF Cart Subtotal From Collection
IF Cart Subtotal Is Greater Than → $50.00 From Collection → "clothing"
RETURN Specific Product → [Free Gift Product]
This rule fires only when the combined price of cart items belonging to the clothing collection is greater than $50.00. Items outside the clothing collection do not count toward the total, so the gift unlocks based on clothing spend alone rather than the full cart subtotal.
(Image example above: Cart Subtotal rule With From Collection condition)
IF Cart Line Item Count Rule
The Cart Line Item Count rule targets the rule based on the number of distinct line items in the cart, regardless of quantity. Two of the same product count as one line item. Two different variants of the same product count as two separate line items.
Operators: Is Greater Than, Is Less Than, Is Equal To. Value: a number.
Example: a cart holding 2 of Item A counts as 1 line item. A cart holding Item A and Item B counts as 2 line items.
(Image example above: Cart Line Item Count rule in the Data Source rule builder)
Add Condition: Scope Cart Line Item Count by Tag or Collection
Click Add Condition on the Cart Line Item Count rule to scope the count to a subset of cart items. Two scoping options are available.
With Tag: counts only cart line items whose product has the specified Shopify product tag.
From Collection: counts only cart line items whose product belongs to the specified Shopify collection.
IF Cart Line Item Count Is Greater Than → 2 With Tag → "apparel"
RETURN Specific Product → [Free Gift Product]
This rule fires only when the cart holds more than two distinct line items tagged apparel, then returns the gift product.
Note: A With Tag condition matches the full tag exactly and is not case-sensitive, so apparel matches a product tag of Apparel but not apparel-mens.
A From Collection condition matches on the exact Shopify collection. If you add more than one condition to a count rule, the conditions are additive rather than combined with AND, and a product that satisfies two conditions is counted twice. To avoid unexpected counts, use a single condition per count rule.
IF Cart Total Item Count Rule
The Cart Total Item Count rule targets the rule based on the total quantity of items in the cart, including duplicates (three of the same product count as three items).
Operators: Is Greater Than, Is Less Than, Is Equal To.
Value: a number.
Example: a cart holding 2 of Item A and 1 of Item B counts as 3 total items.
(Image example above: Cart Total Item Count rule in the Data Source rule builder)
Add Condition: Scope Cart Total Item Count by Tag or Collection
Click Add Condition on the Cart Total Item Count rule to scope the count to a subset of cart items. Two scoping options are available.
With Tag: counts only cart items whose product has the specified Shopify product tag.
From Collection: counts only cart items whose product belongs to the specified Shopify collection.
Example:
IF Cart Total Item Count Is Greater Than → 3 From Collection → "Shirts"
RETURN Collection → "Pants" → Sort By: Smart Sort
This rule fires only when the cart holds more than three total items from the Shirts collection, then returns products from the Pants collection.
IF Discount Code Rule
The Discount Code rule targets the rule based on the discount codes currently applied to the shopper's cart. Rebuy reads the codes the storefront reports as applied, including codes entered in the Smart Cart discount field.
Operators: Contains, Does Not Contain, Equals, Does Not Equal.
Value: a discount code, or part of a code.
How the operators match:
With Equals or Does Not Equal, the rule matches the full code exactly. With Contains or Does Not Contain, the rule matches a partial code, so a value of SUMMER fires for an applied code of SUMMER25. Matching is not case-sensitive, so SUMMER and summer are treated the same.
If more than one code is applied to the cart, the rule fires when any applied code matches the value. Rebuy matches against the codes the cart reports as applied and does not re-check whether the code is still valid in Shopify.
⚠️ The Discount Code rule is not supported for Post Purchase Offer widgets.
Example: Discount Code Contains
IF Discount Code Contains → "VIP"
RETURN Specific Product → [VIP Gift Product]
This rule returns the VIP gift product whenever an applied code contains VIP.
Discount Code Rule Limitations
Automatic discounts are not evaluated. The Discount Code rule evaluates only manually entered discount codes. Automatically applied discounts, such as Buy X Get Y offers and automatic percentage-off discounts, are not captured by this condition, because no code is entered for the cart to report.
The Discount Code rule is not supported for Post Purchase Offer widgets.
Frequently Asked Questions About Cart Rules
Can I scope a cart item count rule to a specific tag or collection?
The Cart Line Item Count rule and the Cart Total Item Count rule both support an Add Condition option that scopes the count to a subset of cart items. Choose With Tag to count only items carrying a specific Shopify product tag, or From Collection to count only items belonging to a specific Shopify collection.
Can I apply a cart subtotal rule to spend on a specific collection or tag?
The Cart Subtotal rule supports an Add Condition option that measures spend on a subset of the cart. Choose With Tag to sum only items carrying a specific Shopify product tag, or From Collection to sum only items in a specific Shopify collection. Only one condition is allowed per Cart Subtotal rule, and spend cannot be scoped by vendor. A promotion like "$10 off when you spend $50 on a specific vendor's products" is only possible if those products share a tag or collection you can scope to.
What is the difference between Cart Line Item Count and Cart Total Item Count?
Cart Line Item Count counts distinct line items in the cart regardless of quantity, so 2 of the same product count as 1. Cart Total Item Count counts the total quantity of all items including duplicates, so 2 of the same product count as 2. Use Cart Line Item Count to react to how many different products are in the cart, and Cart Total Item Count to react to total units.
Will the Discount Code rule re-check whether a code is still valid in Shopify?
The Discount Code rule matches against the codes the cart currently reports as applied and does not re-validate them against Shopify. If a code is applied to the cart, the rule treats it as a match based on the operator and value you set.
Does the Discount Code rule work with automatic discounts?
The Discount Code rule evaluates only manually entered discount codes. Automatic discounts, such as Buy X Get Y offers and automatic percentage-off discounts, are not captured, because no code is entered for the cart to report.
Which widgets support the Discount Code rule?
The Discount Code rule is available for Checkout Extensions and onsite widgets (Smart Cart, product page, collection page, homepage, and cart page). It is not supported for Post Purchase Offer widgets.















