Use Cart Attribute and Line Item Property rules to show recommendations based on the data your store already saves to a shopper's cart, such as quiz answers, gift messages, engraving text, delivery dates or configurator selections. Use this article to choose the right rule, set it up and test it, and see how Cart Attribute and Line Item Property rules work in checkout, in post-purchase offers and on headless storefronts.
What cart attributes and line item properties are
Cart attributes and line item properties are Shopify's way of attaching custom key-value data to a cart, such as a key of skin_type with a value of dry. Your quiz app, product configurator, theme code or a custom script writes this data to the cart, and the Cart Attribute and Line Item Property Data Source rules read it when Rebuy chooses which products to show.
The following table shows where each kind of data lives in the cart, which Data Source rule reads it, and examples of each.
Data | Where it lives in the cart | Data Source rule that reads it | Examples |
Cart attribute | One set for the whole cart | Cart Attribute | A quiz result, a gift note, a requested delivery date, a campaign code |
Line item property | One set on each product line in the cart | Line Item Property | Engraving text on one necklace, a monogram on one towel, a configurator selection |
To choose between the Cart Attribute rule and the Line Item Property rule, ask whether the field belongs to the order or to one product. A field that holds one value for the whole cart is a cart attribute and needs the Cart Attribute rule, and a field that each product in the cart can carry separately is a line item property and needs the Line Item Property rule.
In a cart, cart attributes and line item properties look like this:
cart.attributes = { "skin_type": "dry", "delivery_date": "2026-12-24" }
cart.items[0].properties = { "Engraving": "For Mom", "Font": "Script" }
cart.items[1].properties = { "Engraving": "For Dad", "Font": "Block" }
Example:
Keys Rebuy and other apps add to the cart
Rebuy writes some cart attributes and line item properties of its own, and Cart Attribute and Line Item Property rules read them like any other key. With attribution tracking on, the Smart Cart adds the cart attributes _source and _attribution, and items added through a Rebuy widget carry line item properties such as _widget_id, _source and _attribution. Other apps and tracking tools often add keys of their own too. These keys are why a Cart Attribute or Line Item Property rule should name a specific key whenever it uses Does Not Equal or Does Not Contain, as explained in Use a specific key with Does Not Equal and Does Not Contain.
Add a Cart Attribute or Line Item Property rule
Adding a Cart Attribute or Line Item Property rule starts with finding the exact key your store writes to the cart, and then building the rule in the Data Source editor.
Find the exact key in your cart
Finding the exact key is the first step, since a Cart Attribute or Line Item Property rule set to Equals only matches a key spelled and capitalized the same way. On your live storefront, add the product and any customization to your cart, then open https://your-store.com/cart.js in the same browser, replacing your-store.com with your store's domain. Cart attributes are listed under attributes, and each item's line item properties are listed under that item's properties.
Copy the key exactly as it appears, including capitalization, spaces and underscores. If the field you expect is missing from /cart.js, nothing on your storefront is writing it to the cart yet, so the app or script that collects the information is where it needs to be set up. A headless storefront has no /cart.js, so see Use Cart Attribute and Line Item Property rules on a headless storefront.
Build the rule in the Data Source editor
Building a Cart Attribute or Line Item Property rule takes the key you copied from your cart and the value you want to match.
In Rebuy, go to Data Sources and open the Data Source you want to change, or create a new one.
Add a rule, then select Cart Attribute or Line Item Property in the IF dropdown.
Set the Key operator and enter the key exactly as it appears in your cart.
Set the Value operator and enter the value.
Set the RETURN to the products the rule should show when it matches.
Save the Data Source.
Test the rule in the Data Source previewer, as described in Test a Cart Attribute or Line Item Property rule in the previewer. If the rule does not match, work through Troubleshoot a Cart Attribute or Line Item Property rule that does not match.
Picking a value in the IF dropdown also shows a short description under it. Cart Attribute describes key-value pairs set on the Shopify cart by external tools, custom scripts or apps, and Line Item Property describes per-product properties set on cart line items by Shopify, Rebuy widgets, custom scripts or apps.
Start from a preset
The Presets buttons above the Key and Value fields of a Cart Attribute or Line Item Property rule set a common operator combination in one click. You still enter the key or value yourself afterward. The following table lists what each preset sets and when to use it.
Preset | Key operator | Value operator | Use it to match |
Key Exists | Equals | Is Anything | A specific key, whatever its value |
Value Scan | Is Anything | Contains | A value containing your text, under any key |
Key + Value | Contains | Equals | A key containing your text with an exact value |
How the Key and Value conditions match
Every Cart Attribute and Line Item Property rule has a Key condition and a Value condition, each with its own operator. The Key condition checks the name of the attribute or property, such as skin_type, and the Value condition checks its value, such as dry.
Operators for the Key and Value conditions
The following table lists the operators available in the Key and Value conditions of a Cart Attribute or Line Item Property rule, what each one matches, and whether it is case-sensitive.
Operator | Where it is available | Matches when | Case-sensitive |
Is Anything | Key and Value | Any key, or any value. Use it when you only care about the other side | Not applicable |
Equals | Key and Value | The text matches exactly, in full | Yes |
Contains | Key and Value | The text appears anywhere in the key or value | No |
Does Not Equal | Value | The attribute is set, and its value is anything other than this exact text | Yes |
Does Not Contain | Value | The attribute is set, and its value does not include this text | No |
When a Key or Value operator is case-sensitive, the editor shows a Key is case-sensitive. or Value is case-sensitive. note under the field, since Dry and dry are different values under Equals. A rule with Is Anything in the Key condition and Is Anything in the Value condition matches every cart, including a cart with no attributes or properties at all.
The key and value must match on the same attribute
A Cart Attribute or Line Item Property rule with a specific Key and a specific Value matches only when a single attribute satisfies the Key condition and the Value condition together. Finding the key on one attribute and the value on a different attribute is not a match.
For example, take a cart with these cart attributes:
{ "skin_type": "oily", "hair_type": "dry" }
A Cart Attribute rule of Key Equals skin_type and Value Equals dry does not match this cart, since the value dry belongs to hair_type. That is what makes the rule mean "skin type is dry" and not "the words skin_type and dry both appear somewhere in the cart."
Match on the key only or on the value only
To match on one side of a Cart Attribute or Line Item Property rule only, set the other side to Is Anything. The following table shows common goals and the Key and Value settings for each.
Goal | Key | Value |
A gift message was entered, whatever it says | Equals | Is Anything |
Any attribute in the cart has the value | Is Anything | Equals |
Every cart matches | Is Anything | Is Anything |
Does Not Equal and Does Not Contain need the attribute to be set
A Cart Attribute or Line Item Property rule with a Value of Does Not Equal or Does Not Contain matches when the attribute is in the cart with a value other than your text. When the attribute is missing from a shopper's cart, that rule does not match for the shopper, and the Data Source moves on to its next rule. The following table shows examples of what these rules match.
Rule | Matches | Does not match |
Cart Attribute, Key Equals | The quiz was taken and the answer was not dry, such as |
|
Line Item Property, Key Equals | A cart with at least one engraved item whose engraving does not mention Mom | A cart with no |
To show something to shoppers whose cart does not have an attribute at all, see Target shoppers who have not set an attribute.
Use a specific key with Does Not Equal and Does Not Contain
Pair a Value of Does Not Equal or Does Not Contain with a Key set to Equals or Contains, so the rule reads as "this attribute is set to something else." With the Key set to Is Anything, a Cart Attribute or Line Item Property rule checks every attribute in the cart, including the keys Rebuy, other apps and your theme add, and it matches as soon as any one of them does not equal your value.
Note: A Cart Attribute rule with Key Is Anything and Value Does Not Equal matches far more carts than it seems to. A Smart Cart session with attribution tracking on already carries Rebuy's _source attribute, and its value does not equal whatever you entered, so the rule matches that cart. The Data Source editor shows a note under a rule set up this way and still lets you save it. To check a single attribute, set the Key to Equals.
Key operators in Cart Attribute and Line Item Property rules
The Key condition of a Cart Attribute or Line Item Property rule offers Is Anything, Equals and Contains, and Does Not Equal and Does Not Contain are offered in the Value condition. A Key of Does Not Equal gift_note would match any cart holding any other attribute, including the attributes Rebuy and other apps add to most carts, so the rule would match nearly every cart. To show different products to carts that do not have a specific key, use the rules in Target shoppers who have not set an attribute. If your setup needs a negated key that those rules do not cover, contact Rebuy Support with the use case.
Line Item Property rules check every item in the cart
A Line Item Property rule matches when any one item in the cart satisfies the rule's Key and Value conditions on that same item. A Line Item Property rule does not need every item to match, does not report which item matched, and does not count how many items match.
For example, in a cart where only the second item has engraving, a Line Item Property rule of Key Equals Engraving and Value Is Anything matches. The any-item behavior applies to Does Not Equal and Does Not Contain too. A cart holding one item engraved For Mom and another engraved For Dad matches a Line Item Property rule of Key Equals Engraving and Value Does Not Contain Mom, since the For Dad item satisfies it.
To act only when no engraved item mentions Mom, place a Line Item Property rule of Key Equals Engraving and Value Contains Mom above it, with Exit If Matched turned on. Carts with a Mom engraving stop at that rule, and the Does Not Contain rule below it only sees the rest.
Test a Cart Attribute or Line Item Property rule in the previewer
The Data Source previewer has Cart Attributes and Line Item Properties sections, where you add key and value rows to simulate a cart and see what a Cart Attribute or Line Item Property rule returns without building a real cart on your storefront.
In the Data Source editor, click Preview Ruleset.
To test a Cart Attribute rule, click Add attribute in the Cart Attributes section and enter a key and a value. To test a Line Item Property rule, click Add property in the Line Item Properties section instead.
Click Simulate.
Check Data Source: Rules to see whether the rule matched, and Data Source: Output for the products it returned.
The previewer confirms the rule's logic, and a live storefront test confirms the attribute actually arrives from your store. If the rule matches in the previewer and not on your storefront, the attribute is not reaching Rebuy from your cart, so compare the key in /cart.js with the key in the rule.
Target shoppers who have not set an attribute
Targeting shoppers whose cart does not have a specific attribute takes rules placed in a set order, since a Value of Does Not Equal or Does Not Contain never matches a cart that is missing the attribute. Set up the following rules in this order:
IF Cart Attribute, Key Equals
skin_quiz, Value Is Anything, RETURN the products for quiz takers, with Exit If Matched turned on.IF Anything, RETURN the products for shoppers who have not taken the quiz.
Shoppers whose cart has a skin_quiz attribute stop at the first rule, and every other shopper continues to the next rule.
Where Cart Attribute and Line Item Property rules work
Cart Attribute and Line Item Property rules work wherever Rebuy receives the cart, with one exception for post-purchase offers. The following table shows where each rule matches.
Where the Data Source runs | Cart Attribute rule | Line Item Property rule |
Smart Cart and on-site widgets | Matches | Matches |
Checkout Extensions | Matches | Matches |
Post-purchase offers | Matches | Does not match, so the Data Source moves on to its next rule |
Smart Cart and cart widgets check Cart Attribute and Line Item Property rules again every time the cart changes. A product page widget reads the cart as it was when the page loaded.
Post-purchase offers use cart attributes only
Post-purchase offers match Cart Attribute rules and still show when a Data Source uses a Line Item Property rule, with the offer coming from the Data Source's next matching rule, since a Line Item Property rule does not match in a post-purchase Data Source. If a post-purchase offer depends on per-item data such as engraving text, have the app that writes the line item property also save the information as a cart attribute, then target it with a Cart Attribute rule.
Use Cart Attribute and Line Item Property rules on a headless storefront
Cart Attribute and Line Item Property rules work on a headless storefront once your developer passes the cart data in your storefront's Rebuy API requests. Checkout Extensions and post-purchase offers need no extra work, since they run inside Shopify's checkout however your storefront is built. Rebuy Support does not build or troubleshoot headless storefront code.
A headless storefront's Rebuy API requests need to include the following:
cart[attributes], with the cart's attributes as a JSON object.cart[items][i][properties]for each line item, with that item's properties as a JSON object.
A headless storefront has no /cart.js, which belongs to Shopify's online store, so find your exact keys through the Storefront API instead, under the cart's attributes and each line's attributes. Shopify's Storefront API calls line item properties line attributes, so map each line's attributes into Rebuy's properties parameter.
URL-encode each JSON object exactly once. If your HTTP client already encodes parameter values, pass the raw JSON string and let the client encode it. When a payload is encoded twice, your widgets still show products, from the Data Source's next matching rule, since Rebuy reads that request as a cart with no attributes and Cart Attribute and Line Item Property rules with a specific key or value do not match it.
Troubleshoot a Cart Attribute or Line Item Property rule that does not match
When a Cart Attribute or Line Item Property rule does not match a cart you expect it to, check the following in order:
Open
/cart.json a live cart and confirm the key is there, spelled and capitalized exactly as in your rule.If the rule uses Equals or Does Not Equal, check capitalization in the key and the value. Switching the operator to Contains is a quick way to test whether capitalization is the cause.
Confirm the key and the value sit on the same attribute, as explained in The key and value must match on the same attribute.
If the rule uses Does Not Equal or Does Not Contain, confirm the attribute is in the cart, since a negated value never matches a missing key.
Check the rules above it in the Data Source. A rule higher up with Exit If Matched turned on stops the Data Source before it reaches your rule.
Enter the exact key and value from
/cart.jsin the previewer's Cart Attributes or Line Item Properties section and click Simulate. If the rule matches there and not on your storefront, the attribute is not reaching Rebuy from your cart. If the rule does not match in the previewer either, the rule's settings need to change.
Ways to use Cart Attribute and Line Item Property rules
Cart Attribute and Line Item Property rules let the products a shopper sees reflect what the shopper told you, not only what they clicked. Merchants use them in the following ways:
A skin quiz writes
skin_type: dryto the cart, and a Cart Attribute rule shows a dry-skin routine in the Smart Cart, on product pages and in checkout.A cart with
is_gift: trueor a filled-ingift_messageattribute returns gift wrap, a card and a premium add-on.An item with an
Engravingline item property returns a presentation box, a care kit or a second personalized piece.A product configurator writes the selected build to line item properties, and a Line Item Property rule returns the accessories that fit it.
A landing page writes
campaign: creator-xto the cart, and a Cart Attribute rule returns that creator's picks for the rest of the session.A
delivery_dateattribute from a delivery or subscription app lets you offer something different to a shopper scheduling a December 24th delivery.A Cart Attribute rule of Key Equals
skin_quizand Value Does Not Equalsensitiveshows the standard routine to every quiz taker except those who answered sensitive, who get their own rule.
Limitations of Cart Attribute and Line Item Property rules
Cart Attribute and Line Item Property rules have the following limits. Each one names what works instead.
Rebuy reads cart attributes and line item properties and does not write your own fields. A Cart Attribute or Line Item Property rule matches only when your quiz app, configurator, theme or script has written the data to the cart.
Cart attributes and line item properties last as long as the cart. They do not follow a shopper to another device, and an abandoned cart takes them with it. For a signal that should stay with the customer, such as a skin type or a membership tier, a customer tag or customer metafield is a more durable home.
Post-purchase offers match Cart Attribute rules only. Post-purchase offers still show, and a Line Item Property rule in a post-purchase Data Source is passed over in favor of the next matching rule. Save per-item data as a cart attribute too when a post-purchase offer depends on it.
Cart Attribute and Line Item Property rules compare text, not numbers. A rule cannot check that a value is greater than 3. For number-based cart logic, use the Cart Subtotal, Cart Line Item Count or Cart Total Item Count rules.
The Key condition offers Is Anything, Equals and Contains. Does Not Equal and Does Not Contain are offered in the Value condition, where a specific key keeps them precise.
A Line Item Property rule tells you an item with that property is in the cart. It does not say which item, and it does not count how many items have the property.
Unreadable cart data counts as a cart with no attributes. When Rebuy cannot read the attributes or properties sent with a request, the widget shows the products from the Data Source's next matching rule, since Cart Attribute and Line Item Property rules with a specific key or value, including Does Not Equal and Does Not Contain, do not match. A rule with Is Anything on both sides still matches. On a standard Shopify theme Rebuy reads the cart for you, and unreadable data usually comes from a headless storefront's code encoding the cart data twice, as described in Use Cart Attribute and Line Item Property rules on a headless storefront.
Keys can contain letters, numbers, spaces, hyphens, underscores and dots. A key with any other character shows an error in the editor and in the previewer, and the Data Source cannot be saved or previewed until the key is corrected.
Frequently Asked Questions About Cart Attribute and Line Item Property Rules
Can a Data Source rule read cart attributes from an A/B testing tool such as Intelligems?
Yes, a Data Source can read the cart attributes an A/B testing tool such as Intelligems writes to the cart, using a Cart Attribute rule. Testing tools commonly save the shopper's test group as a cart attribute, so a Cart Attribute rule on that key can show different products to each group. To find the key and value your testing tool uses, open /cart.js on a cart in each test group and copy them exactly into the rule.







