Shopify discounts based on line item properties
Updated · SMART Functions Creator (E-TRADE PARTNER)
SMART Functions Creator can apply a configured product discount only to cart lines whose line item property matches a chosen value. Create a Line group with the Line item property/attribute condition, then target a Product discount at that group. Your theme or product-options app must send the property when adding the item to the cart. A label or checkbox that exists only on the product page is not enough.
5.0 · SMART Functions Creator builds this as a Shopify Function, free on live stores, no code.
Install freeOn this page
Example: 15% off items marked for an offer
Suppose your storefront sends the property _offer = custom on selected items. You want those lines to receive 15% off, while an ordinary purchase of the same variant stays at its regular price. The key, value, percentage, and prices below are illustrative; use the actual property your storefront sends.
| Setting | Value for this example |
|---|---|
| Function type | Discount |
| Application method | Automatic |
| Function input | Attribute input |
| Line group | Offer items |
| Line group condition | Line item property/attribute |
| Property key / operator / value | _offer / is / custom |
| Rule action | Product discount |
| Discount | Percentage off: 15 |
| Apply to | Line groups: Offer items |
| Apply to first X products | 0, meaning all eligible units |
Set up the rule
- Confirm the exact property key and value in the cart data your theme or product-options app sends. Include any leading underscore in the key. A cart-wide attribute is a different input from a line item property.
- Create a Discount function and choose Automatic as the Application method. Add a Product discount rule. On a new function, the input can switch to fit the condition you add; this example requires Attribute input.
- In the Line groups card, choose Add line group and name it Offer items. Add Line item property/attribute, enter _offer as the key, choose is, and enter custom as the value.
- In the Product discount action, choose Percentage off and enter 15. Set Apply to to Line groups and select Offer items. Leave Apply to first X products at 0 to include every matching unit.
- Set a clear Discount label, such as Custom offer 15%. Review purchase eligibility, Combinations, and Active dates before saving. A newly saved discount may already be active when its start date is current; use a future start date while preparing a live-store promotion.
- Run the checks below in a test store or during a controlled test window. Confirm the function and the rule are enabled and the discount's start time has arrived. Check the result at checkout as well as in the cart.
Expected results
Assume each unit costs 20.00 in your store currency and no other discount applies. These are expected merchandise prices for this example, before shipping and tax.
| Cart line | This rule's result |
|---|---|
| 1 unit, _offer = custom | 3.00 discount; merchandise price 17.00 |
| 2 units, _offer = custom | 6.00 discount; merchandise price 34.00 |
| 1 unit, _offer = standard | No discount from this rule |
| 1 unit with no _offer property | No discount from this rule |
| One custom line and one ordinary line of the same variant | Only the matching custom line receives 15% off |
When a property is missing
There is no dedicated property is absent operator in this editor. A negative comparison such as _offer is not custom also matches missing or empty values. However, it matches other nonempty values too. For example, _offer = seasonal also qualifies. Do not describe that condition as an absence-only check.
If your storefront uses a known list of offer markers, you can exclude that list with a negative comparison and target the remaining lines with another rule. Keep the list current: an unexpected new marker can enter the remaining group. Test a missing value and an unfamiliar nonempty value separately before relying on this pattern.
Offer items and standalone quantity discounts
A merchant may buy the same variant inside an offer and separately. Keep the two cart lines in different Line groups: one matches the offer property; the other excludes the known offer values. A Product discount can target the first, and a Volume discount can target the second. That keeps the promotion's conditions attached to the correct cart lines. Use the volume guide for grouping and highest-tier behavior, and combination settings when other discounts are active.
Limits to check before building
- All line-property conditions in one function share one property key. Changing that key updates the other line-property conditions in the function. You can compare different values of the same key.
- Input types cannot be freely mixed. Once a function is created, its Function input is locked. Check compatibility before adding unrelated conditions; see inputs and metafields.
- A property can qualify a line for a configured discount. The Product discount editor does not calculate arbitrary prices or percentages from numbers stored in properties.
- A customer-supplied property is not proof of membership or permission to set a price. Use it for the intended offer design and check how your storefront allows it to be set.
- A parent bundle line does not automatically expose each selected component as a separate cart line. The condition can only match the data Shopify passes to this function.
Why the rule is not applying
- The product page displays the option but does not send a line property to the cart. Ask the theme or options-app developer for the actual key and value.
- The action still targets all products, or a different Line group, instead of Offer items.
- The function has the wrong input, is inactive, or has not reached its start date.
- Another promotion changes which discount Shopify selects. Test the isolated offer, then the combination you intend to use.
The same configured line-property condition is available for payment customizations, delivery customizations, and checkout validation with the compatible input. This guide uses a Product discount; the other function types have different actions. Follow the troubleshooting checklist when testing a different type.
Create a discount for the right cart lines
SMART Functions Creator is free on live stores and rated 5.0 stars across 110+ Shopify App Store reviews.
Install free5.0 stars · 110+ reviews
Further reference
Shopify's Discount Function API includes discounts on cart lines with properties as a use case. The setup and limits above describe SMART Functions Creator's current rule editor.
Frequently asked questions
›Can I discount two lines of the same variant differently?
Yes, when Shopify supplies them as separate cart lines with different property values. Target the matching Line group and test that the ordinary line remains outside it.
›Does is not custom mean the property is absent?
No. It also matches other nonempty values. Missing and empty values can satisfy this negative condition, but it is not an absence-only operator.
›Can one function read multiple line-property keys?
The current editor shares one key across line-property conditions in a function. Multiple comparisons can use different values of that key.