[{"data":1,"prerenderedAt":581},["ShallowReactive",2],{"bootstrap":3,"blog-close-the-promotion-gap-with-intelligent-upselling":277},{"navigation":4,"globalConfig":196,"forms":218},{"headerSections":5,"headerFooterLinks":67,"footer":76,"legalLinks":153,"socialLinks":176},[6,39,44,50,57,62],{"hasSubMenu":7,"title":8,"links":9,"columns":38},true,"Product",[10,20,26,32],{"showTag":11,"_modelApiKey":12,"text":13,"subtitle":14,"icon":15,"isExternal":11,"link":16,"openForm":11},false,"navigation_link","Universal checkout","Sell anywhere","globe-simple",{"_modelApiKey":17,"slug":18,"title":19},"page","universal-checkout","Universal Checkout",{"showTag":11,"_modelApiKey":12,"text":21,"subtitle":22,"icon":23,"isExternal":11,"link":24,"openForm":11},"Distributed OMS","Manage orders","package",{"_modelApiKey":17,"slug":25,"title":21},"distributed-oms",{"showTag":11,"_modelApiKey":12,"text":27,"subtitle":28,"icon":29,"isExternal":11,"link":30,"openForm":11},"Promotion engine","Automated discounts","seal-percent",{"_modelApiKey":17,"slug":31,"title":27},"promotion-engine",{"showTag":11,"_modelApiKey":12,"text":33,"subtitle":34,"icon":35,"isExternal":11,"link":36,"openForm":11},"POS system","Operate stores","devices",{"_modelApiKey":17,"slug":37,"title":33},"pos-system",2,{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":40,"isExternal":11,"link":41,"openForm":11,"title":40},"Pricing",{"_modelApiKey":42,"slug":43},"pricing_page","pricing",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":45,"isExternal":11,"link":46,"openForm":11,"title":45},"Customers",{"_modelApiKey":47,"slug":48,"title":49},"customer_landing_page","customers","Customers page",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":51,"isExternal":11,"link":52,"openForm":11,"form":54,"title":51},"Partners",{"_modelApiKey":17,"slug":53,"title":51},"partners",{"_modelApiKey":55,"slug":53,"name":56},"form","PartnersForm",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":58,"label":59,"isExternal":7,"url":60,"openForm":11,"title":61},"Docs Hub","Learn more","https:\u002F\u002Fdocs.commercelayer.io\u002F","Docs",{"hasSubMenu":11,"showTag":11,"_modelApiKey":12,"text":63,"isExternal":11,"link":64,"openForm":11,"title":63},"Blog",{"_modelApiKey":65,"slug":66},"blog_landing_page","blog",[68,72],{"text":69,"link":70},"Sign in",{"_modelApiKey":12,"text":69,"isExternal":7,"url":71,"openForm":11},"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_in",{"text":73,"link":74},"Sign up for free",{"_modelApiKey":12,"text":73,"isExternal":7,"url":75,"openForm":11},"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_up",[77,89,109,132],{"hasSubMenu":7,"title":8,"links":78},[79,81,83,85,87],{"showTag":11,"_modelApiKey":12,"text":13,"subtitle":14,"icon":15,"isExternal":11,"link":80,"openForm":11},{"_modelApiKey":17,"slug":18,"title":19},{"showTag":11,"_modelApiKey":12,"text":21,"subtitle":22,"icon":23,"isExternal":11,"link":82,"openForm":11},{"_modelApiKey":17,"slug":25,"title":21},{"showTag":11,"_modelApiKey":12,"text":27,"subtitle":28,"icon":29,"isExternal":11,"link":84,"openForm":11},{"_modelApiKey":17,"slug":31,"title":27},{"showTag":11,"_modelApiKey":12,"text":33,"subtitle":34,"icon":35,"isExternal":11,"link":86,"openForm":11},{"_modelApiKey":17,"slug":37,"title":33},{"showTag":11,"_modelApiKey":12,"text":40,"isExternal":11,"link":88,"openForm":11},{"_modelApiKey":42,"slug":43},{"hasSubMenu":7,"title":90,"links":91},"Resources",[92,94,99,104,107],{"showTag":11,"_modelApiKey":12,"text":93,"isExternal":7,"url":60,"openForm":11},"Documentation",{"showTag":11,"_modelApiKey":12,"text":95,"label":95,"isExternal":11,"link":96,"openForm":11},"Agentic Commerce",{"_modelApiKey":17,"slug":97,"title":98},"agentic-commerce-whitepaper","Agentic Commerce Whitepaper",{"showTag":11,"_modelApiKey":12,"text":100,"isExternal":11,"link":101,"openForm":11},"Core concepts",{"_modelApiKey":17,"slug":102,"title":103},"headless-commerce","Headless commerce",{"showTag":11,"_modelApiKey":12,"text":105,"isExternal":7,"url":106,"openForm":11},"Changelog","https:\u002F\u002Fdocs.commercelayer.io\u002Fchangelog\u002F",{"showTag":11,"_modelApiKey":12,"text":63,"isExternal":11,"link":108,"openForm":11},{"_modelApiKey":65,"slug":66},{"hasSubMenu":7,"title":110,"links":111},"Company",[112,116,118,121,126],{"showTag":11,"_modelApiKey":12,"text":113,"isExternal":11,"link":114,"openForm":11},"Vision",{"_modelApiKey":17,"slug":115,"title":113},"vision",{"showTag":11,"_modelApiKey":12,"text":45,"isExternal":11,"link":117,"openForm":11},{"_modelApiKey":47,"slug":48,"title":49},{"showTag":11,"_modelApiKey":12,"text":51,"isExternal":11,"link":119,"openForm":11,"form":120},{"_modelApiKey":17,"slug":53,"title":51},{"_modelApiKey":55,"slug":53,"name":56},{"showTag":11,"_modelApiKey":12,"text":122,"isExternal":11,"link":123,"openForm":11},"Security",{"_modelApiKey":17,"slug":124,"title":125},"security","Security at Commerce Layer",{"showTag":11,"_modelApiKey":12,"text":127,"label":128,"isExternal":11,"openForm":7,"form":129},"Giveback","Giveback program",{"_modelApiKey":55,"slug":130,"name":131},"giveback","GivebackForm",{"hasSubMenu":7,"title":133,"links":134},"Get in touch",[135,140,145,149],{"showTag":11,"_modelApiKey":12,"text":136,"isExternal":11,"openForm":7,"form":137},"Contact",{"_modelApiKey":55,"slug":138,"name":139},"contact","ContactUsForm",{"showTag":11,"_modelApiKey":12,"text":141,"isExternal":11,"openForm":7,"form":142},"Book a demo",{"_modelApiKey":55,"slug":143,"name":144},"demo","RequestDemoForm",{"showTag":11,"_modelApiKey":12,"text":146,"label":147,"isExternal":7,"url":148,"openForm":11},"Support","Email support","mailto:support@commercelayer.io",{"showTag":11,"_modelApiKey":12,"text":150,"label":151,"isExternal":7,"url":152,"openForm":11},"Community","Discord community","https:\u002F\u002Fdiscord.gg\u002Fcommercelayer",{"hasSubMenu":7,"title":154,"links":155},"Legal",[156,161,165,169,173],{"showTag":11,"_modelApiKey":12,"text":157,"label":158,"isExternal":7,"url":159,"openForm":11,"htmlClassNames":160},"Terms","Terms and conditions","\u002Flegal-embed\u002Fterms-of-service","iubenda-nostyle no-brand iubenda-noiframe iubenda-embed",{"showTag":11,"_modelApiKey":12,"text":162,"label":163,"isExternal":7,"url":164,"openForm":11,"htmlClassNames":160},"Privacy","Privacy policy","\u002Flegal-embed\u002Fprivacy-policy",{"showTag":11,"_modelApiKey":12,"text":166,"label":167,"isExternal":7,"url":168,"openForm":11,"htmlClassNames":160},"Cookies","Cookie policy","\u002Flegal-embed\u002Fcookie-policy",{"showTag":11,"_modelApiKey":12,"text":170,"isExternal":7,"url":171,"openForm":11,"htmlClassNames":172},"Notice at collection","#","iubenda-cs-uspr-link",{"showTag":11,"_modelApiKey":12,"text":174,"isExternal":7,"url":171,"openForm":11,"htmlClassNames":175},"Privacy preferences","iubenda-cs-preferences-link",[177,180,184,188,192],{"title":178,"type":179,"url":152,"isExternal":7},"Discord","discord-logo",{"title":181,"type":182,"url":183,"isExternal":7},"Github","github","https:\u002F\u002Fgithub.com\u002Fcommercelayer",{"title":185,"type":186,"url":187,"isExternal":7},"Bluesky","bluesky-logo","https:\u002F\u002Fbsky.app\u002Fprofile\u002Fcommercelayer.io",{"title":189,"type":190,"url":191,"isExternal":7},"X","x-logo","https:\u002F\u002Fx.com\u002Fcommercelayer",{"title":193,"type":194,"url":195,"isExternal":7},"LinkedIn","linkedin","https:\u002F\u002Fwww.linkedin.com\u002Fcompany\u002Fcommerce-layer",{"pagesWithoutCtaPanel":197,"ctaPanel":198,"notification":208,"showApiResponseTime":11,"newsletterSignup":216},[],{"title":199,"subtitle":200,"ctas":201},"Ready to get started?","Discover how we can help your business.",[202,205],{"_modelApiKey":203,"text":204,"isExternal":7,"url":75,"openForm":11},"link","Get started for free",{"_modelApiKey":203,"text":206,"isExternal":11,"openForm":7,"form":207},"Contact us",{"_modelApiKey":55,"slug":138,"name":139},{"showNotification":7,"link":209,"linkText":210,"text":215},{"_modelApiKey":203,"text":210,"isExternal":11,"link":211,"openForm":11},"Read article",{"_modelApiKey":212,"slug":213,"title":214},"blog_post","the-new-payments-api-built-for-how-people-pay-now","The new Payments API. Built for how people pay now.","\u003Cp>The new Payments API. Built for how people pay now.\u003C\u002Fp>\n",{"ctaText":217},"Subscribe",[219,225,229,236,240,246,249,253,261,262,267,272,274],{"_modelApiKey":55,"slug":220,"pardotFormEmbedCode":221,"formEmbedMinHeight":222,"successTitle":223,"successCopy":224},"agentic-commerce","https:\u002F\u002Fcommercelayer.fillout.com\u002Ft\u002F5w4Khwgxr6us?whitepaper=agentic",520,"Thank you for your request!","We’ll be in touch soon to arrange a date and time for your personalized demo.",{"_modelApiKey":55,"slug":226,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"successTitle":223,"successCopy":224},"shopify","https:\u002F\u002Fform.fillout.com\u002Ft\u002FgVnLSmKZwRus",850,{"_modelApiKey":55,"slug":130,"pardotFormEmbedCode":230,"formEmbedMinHeight":231,"displayTitle":232,"copy":233,"successTitle":234,"successCopy":235},"https:\u002F\u002Fform.fillout.com\u002Ft\u002FmVDF8aAiofus",500,"We give back.","\u003Cp>Part of Commerce Layer&#39;s company ethos is to empathize and support one another: co-workers, customers, and community. We want to do our part to help nonprofit organizations and small businesses who may feel adversely affected by the current global economic climate, and as a result, need in-kind support to reach their customers.\u003C\u002Fp>\n\n\u003Cp>If this general description matches your organization’s needs, please tell us your story by completing the following form so we can consider helping your cause.\u003C\u002Fp>\n","Thank you!","We will contact you soon to learn more about your story.",{"_modelApiKey":55,"slug":237,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":238,"copy":239},"book-an-onboarding-session","Book an onboarding session","\u003Cp>Schedule some time and our devs will help you set up a Commerce Layer + Sanity store.\u003C\u002Fp>\n",{"_modelApiKey":55,"slug":241,"pardotFormEmbedCode":242,"formEmbedMinHeight":243,"displayTitle":244,"successTitle":234,"successCopy":245},"download-our-whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=ComposableCommerce",450,"Download our whitepaper.","Check your inbox. You should receive a download link soon.",{"_modelApiKey":55,"slug":247,"pardotFormEmbedCode":248,"formEmbedMinHeight":243,"displayTitle":244,"successTitle":234,"successCopy":245},"download-the-content-and-commerce-whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=ContentAndCommerce",{"_modelApiKey":55,"slug":250,"pardotFormEmbedCode":251,"formEmbedMinHeight":243,"displayTitle":244,"copy":252,"successTitle":234,"successCopy":245},"whitepaper","https:\u002F\u002Fform.fillout.com\u002Ft\u002F5YPWmy8oT7us?whitepaper=Jamstack","\u003Cp>Commerce Layer is the perfect platform for building commerce on the Jamstack. Convert any design into pixel perfect HTML pages. Connect a best-of-breed headless CMS. Go serverless and forget the hassle of managing complex infrastructures.\u003C\u002Fp>\n",{"_modelApiKey":55,"slug":254,"pardotFormEmbedCode":255,"formEmbedMinHeight":256,"displayTitle":257,"copy":258,"successTitle":259,"successCopy":260},"contact-links","https:\u002F\u002Fform.fillout.com\u002Ft\u002FeWPyhHGHT7us",750,"Contact us.","\u003Cp>Tell us about your project. Our team will reach out to you for a personalized offer.\u003C\u002Fp>\n","Thanks for your message!","We’ll be in touch soon to discuss your project details.",{"_modelApiKey":55,"slug":138,"pardotFormEmbedCode":255,"formEmbedMinHeight":256,"displayTitle":257,"copy":258,"successTitle":259,"successCopy":260},{"_modelApiKey":55,"slug":263,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":264,"successTitle":265,"successCopy":266},"demo-embed","Want to see it in action? Request a demo.","Thanks for your request!","We’ll be in touch soon to arrange a date and time for your free live demo.",{"_modelApiKey":55,"slug":53,"pardotFormEmbedCode":268,"formEmbedMinHeight":228,"displayTitle":269,"copy":270,"successTitle":234,"successCopy":271},"https:\u002F\u002Fform.fillout.com\u002Ft\u002F9MTkDWMUSqus","Become our partner.","\u003Cp>Join us and get our guidance in helping your clients succeed. Our partners are our ambassadors. We are committed to your success as much as you are.\u003C\u002Fp>\n","We will contact you soon to discuss the details of our partnership.",{"_modelApiKey":55,"slug":273,"pardotFormEmbedCode":268,"formEmbedMinHeight":228,"displayTitle":269,"copy":270,"successTitle":234,"successCopy":271},"partners-embed",{"_modelApiKey":55,"slug":143,"pardotFormEmbedCode":227,"formEmbedMinHeight":228,"displayTitle":275,"copy":276,"successTitle":265,"successCopy":266},"Get a free live demo.","\u003Cp>Get a personalized demo and learn more about what Commerce Layer can do for your company.\u003C\u002Fp>\n",{"_modelApiKey":212,"link":278,"subtitle":283,"date":283,"author":284,"additionalAuthors":294,"icon":295,"abstract":296,"tag":297,"displayTitle":279,"cardRatio":300,"featured":11,"seoMetaTags":301,"layout":365,"blogPostCarousel":303,"_seoMetaTags":542,"authors":576},{"text":279,"isExternal":11,"url":280,"link":281},"Close the promotion gap with intelligent upselling.","",{"_modelApiKey":212,"slug":282},"close-the-promotion-gap-with-intelligent-upselling","March 12, 2026",{"name":285,"picture":286},"Sebastián Ulloa",{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":291,"customData":293},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1772122050-sebastian.jpg","Sebastián Ulloa avatar",1280,"jpg",{"x":292,"y":292},0.5,{},[],"arrow-fat-lines-up","Implement proactive upselling by simulating promotions with the Rules Engine, injecting candidate SKUs into the cart payload, and surfacing contextual offers in real time.",{"color":298,"name":299},"gray","Tutorials","portrait",[302,306,310,313,317,320,323,327,331,335,338,342,346,350,354,357,361],{"attributes":303,"tag":304,"content":305},null,"title","Proactive cart upselling with Commerce Layer",{"attributes":307,"tag":309,"content":303},{"property":308,"content":305},"og:title","meta",{"attributes":311,"tag":309,"content":303},{"name":312,"content":305},"twitter:title",{"attributes":314,"tag":309,"content":303},{"name":315,"content":316},"description","Simulate cart promotions safely and turn qualifying combinations into upsell suggestions that help customers unlock discounts.",{"attributes":318,"tag":309,"content":303},{"property":319,"content":316},"og:description",{"attributes":321,"tag":309,"content":303},{"name":322,"content":316},"twitter:description",{"attributes":324,"tag":309,"content":303},{"property":325,"content":326},"og:image","https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1772122518-check-upsell-thumb.jpg?auto=format&fit=max&w=1200",{"attributes":328,"tag":309,"content":303},{"property":329,"content":330},"og:image:width","1200",{"attributes":332,"tag":309,"content":303},{"property":333,"content":334},"og:image:height","630",{"attributes":336,"tag":309,"content":303},{"name":337,"content":326},"twitter:image",{"attributes":339,"tag":309,"content":303},{"property":340,"content":341},"og:locale","en",{"attributes":343,"tag":309,"content":303},{"property":344,"content":345},"og:type","article",{"attributes":347,"tag":309,"content":303},{"property":348,"content":349},"og:site_name","Commerce Layer",{"attributes":351,"tag":309,"content":303},{"property":352,"content":353},"article:modified_time","2026-03-12T11:33:02Z",{"attributes":355,"tag":309,"content":303},{"property":356,"content":280},"article:publisher",{"attributes":358,"tag":309,"content":303},{"name":359,"content":360},"twitter:card","summary_large_image",{"attributes":362,"tag":309,"content":303},{"name":363,"content":364},"twitter:site","@commercelayer",[366,371,380,383,389,396,406,409,414,421,426,430,432,435,440,443,468,475,477,480,483,485,492,495,498,501,504,507,510,513,516,519,528,531,535],{"_modelApiKey":367,"icon":368,"copy":369,"color":370},"banner","target","\u003Cp>This article is aimed at frontend and backend developers who are already familiar with Commerce Layer APIs and want to implement proactive upselling logic in the cart. If you&#39;re a product manager evaluating the Rules Engine, the first two sections give you the strategic picture — the rest is implementation detail for your team.\u003C\u002Fp>\n","red",{"id":372,"copy":373,"_modelApiKey":374,"listStyle":375,"subtitle":376,"title":377,"darkTheme":11,"buttons":378,"sectionId":379,"color":370},"f0HL9BLyTrOkOnUsmjemlw","\u003Cp>Imagine you have products included in a promotion, but they&#39;re not performing as expected. Is the product itself not appealing? Is the pricing wrong? Or are customers simply unable to identify the right product combinations needed to trigger the promotion?\u003C\u002Fp>\n\n\u003Cp>If the first two aren&#39;t the issue, this article is for you.\u003C\u002Fp>\n\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fapi-reference\u002Fflex_promotions\">Flex promotions\u003C\u002Fa> are automatically applied when a specific set of conditions is met — either within a cart or through a coupon. But there&#39;s a gap: a customer may be just one product away from qualifying for a promotion, with no way for them to know it.\u003C\u002Fp>\n\n\u003Cp>The \u003Ccode>\u002Fapi\u002Frules\u002Fcheck\u003C\u002Fcode> endpoint closes that gap. It lets you \u003Cem>simulate\u003C\u002Fem> whether a set of rules would match a given cart — without actually applying any discounts. Think of it as a dry-run evaluator: you inject hypothetical products into the cart payload, run it against your promotion rules, and if there&#39;s a match, you surface a targeted suggestion in the UI.\u003C\u002Fp>\n","wysiwyg_section","directional","The problem","Understanding the promotion matching gap",[],"the-problem",{"_modelApiKey":367,"icon":381,"copy":382,"color":370},"info","\u003Cp>The check endpoint evaluates conditions and returns a match result  (true or false) per rule — it never executes actions or modifies the order. This is what makes it safe and powerful for upselling scenarios.\u003C\u002Fp>\n",{"_modelApiKey":384,"title":385,"preTitle":386,"linkText":59,"darkTheme":11,"link":387},"link_block","Check and validation","Rules Engine",{"_modelApiKey":203,"text":59,"label":280,"subtitle":280,"icon":280,"isExternal":7,"url":388,"link":303,"anchor":280,"openForm":11,"form":303,"htmlClassNames":280},"https:\u002F\u002Fdocs.commercelayer.io\u002Frules-engine\u002Fcheck-and-validation",{"id":390,"copy":391,"_modelApiKey":374,"listStyle":375,"subtitle":392,"title":393,"darkTheme":11,"buttons":394,"sectionId":395,"color":370},"BWpMyeWmRJ-tKWTJOFaG-A","\u003Cp>The overall flow looks like this:\u003C\u002Fp>\n","The plan","The upsell evaluation flow",[],"the-plan",{"_modelApiKey":397,"border":11,"caption":280,"image":398,"size":405,"darkTheme":11,"rounded":11,"color":370},"image_block",{"url":399,"alt":400,"title":400,"width":401,"height":402,"format":403,"focalPoint":303,"customData":404},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1773248361-upsell-diagram_y-padding.svg","Upsell flow diagram",529,738,"svg",{},"slim",{"_modelApiKey":367,"icon":407,"copy":408,"color":370},"warning","\u003Cp>Before you start, make sure your promotions and products are tagged with \u003Ccode>upsell\u003C\u002Fcode>.\u003C\u002Fp>\n",{"_modelApiKey":384,"title":410,"preTitle":93,"linkText":411,"darkTheme":11,"link":412},"Tagging resources","Read",{"_modelApiKey":203,"text":59,"label":280,"subtitle":280,"icon":280,"isExternal":7,"url":413,"link":303,"anchor":280,"openForm":11,"form":303,"htmlClassNames":280},"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Ftagging-resources",{"id":415,"copy":416,"_modelApiKey":374,"listStyle":375,"subtitle":417,"title":418,"darkTheme":11,"buttons":419,"sectionId":420,"color":370},"USbYL5aiQUGLJsfqirIGvA","\u003Cp>First, retrieve all the flex promotions tagged as \u003Ccode>upsell\u003C\u002Fcode>:\u003C\u002Fp>\n","Step 1","Fetching the promotions",[],"step-1",{"_modelApiKey":422,"code":423,"showLineNumbers":11,"highlightLines":280,"language":424,"size":425},"code_block","GET \u002Fapi\u002Fflex_promotions?filter[q][tags_name_eq]=upsell","shell","Standard",{"_modelApiKey":427,"copy":428,"listStyle":375,"darkTheme":11,"buttons":429,"color":370,"indent":11},"wysiwyg","\u003Cp>For each promotion returned, fetch its full rules payload as follows (where \u003Ccode>{id}\u003C\u002Fcode> is the ID of the single promotion):\u003C\u002Fp>\n",[],{"_modelApiKey":422,"code":431,"showLineNumbers":11,"highlightLines":280,"language":424,"size":425},"GET \u002Fapi\u002Fflex_promotions\u002F{id}",{"_modelApiKey":427,"copy":433,"listStyle":375,"darkTheme":11,"buttons":434,"color":370,"indent":11},"\u003Cp>Store the rules in an array. For this example, we&#39;ll work with two promotions:\u003C\u002Fp>\n",[],{"_modelApiKey":422,"code":436,"showLineNumbers":11,"highlightLines":437,"language":438,"size":439},"[\n  {\n    \"id\": \"p0\",\n    \"name\": \"Get 50% off if product has tag 'on-sale'\",\n    \"conditions\": [\n      {\n        \"field\": \"order.line_items.sku.tags.id\",\n        \"matcher\": \"array_match\",\n        \"value\": {\n          \"in_or\": [\"mJPnBfEezQ\"]\n        },\n        \"group\": \"discountable_items\"\n      }\n    ],\n    \"actions\": [\n      {\n        \"type\": \"percentage\",\n        \"value\": 0.5,\n        \"selector\": \"order.line_items\",\n        \"groups\": [\"discountable_items\"]\n      }\n    ]\n  },\n  {\n    \"id\": \"p1\",\n    \"name\": \"Get 25% off if product is in the summer collection SKU list\",\n    \"conditions\": [\n      {\n        \"field\": \"order.line_items.sku.sku_list_items.sku_list.id\",\n        \"matcher\": \"eq\",\n        \"value\": \"BbpjSNNkAZ\",\n        \"group\": \"discountable_items\"\n      }\n    ],\n    \"actions\": [\n      {\n        \"type\": \"percentage\",\n        \"value\": 0.25,\n        \"selector\": \"order.line_items\",\n        \"groups\": [\"discountable_items\"]\n      }\n    ]\n  }\n]","4,26","json","Wide",{"_modelApiKey":427,"copy":441,"listStyle":375,"darkTheme":11,"buttons":442,"color":370,"indent":11},"\u003Cp>Find here below the ID reference for this tutorial:\u003C\u002Fp>\n",[],{"_modelApiKey":444,"darkTheme":11,"table":445,"size":425},"table_block",{"columns":446,"data":449},[447,448],"ID","Resource",[450,453,456,459,462,465],{"ID":451,"Resource":452},"`mJPnBfEezQ`","Tag `on-sale`",{"ID":454,"Resource":455},"`BbpjSNNkAZ`","SKU list *summer collection*",{"ID":457,"Resource":458},"`DGjtgmdLjW`","Candidate SKU A",{"ID":460,"Resource":461},"`WaDeSyykMZ`","Candidate SKU B",{"ID":463,"Resource":464},"`oKkhYLlzgE`","Customer's current order",{"ID":466,"Resource":467},"`gnYtPpKLeG`","Existing line item in the order",{"id":469,"copy":470,"_modelApiKey":374,"listStyle":375,"subtitle":471,"title":472,"darkTheme":11,"buttons":473,"sectionId":474,"color":370},"SathwC7bTre_yv8rvHWlvA","\u003Cp>Now you need to retrieve all the SKUs tagged as \u003Ccode>upsell\u003C\u002Fcode>, including their tags and SKU lists (both are required because the rules from \u003Cem>Step 1\u003C\u002Fem> reference them):\u003C\u002Fp>\n","Step 2","Fetching the canditate products",[],"step-2",{"_modelApiKey":422,"code":476,"showLineNumbers":11,"highlightLines":280,"language":424,"size":439},"GET \u002Fapi\u002Fskus?filter[q][tags_name_eq]=upsell&include=tags,sku_lists",{"_modelApiKey":427,"copy":478,"listStyle":375,"darkTheme":11,"buttons":479,"color":370,"indent":11},"\u003Cp>From the response, build a candidate array in the following format (normalized to fit the payload structure required by the check endpoint):\u003C\u002Fp>\n",[],{"_modelApiKey":422,"code":481,"showLineNumbers":11,"highlightLines":482,"language":438,"size":439},"[\n  {\n    \"id\": \"DGjtgmdLjW\",\n    \"tags\": [\n      { \"type\": \"tags\", \"id\": \"mJPnBfEezQ\" }\n    ],\n    \"sku_list_items\": [\n      { \"sku_list\": { \"id\": \"BbpjSNNkAZ\" } }\n    ]\n  },\n  {\n    \"id\": \"WaDeSyykMZ\",\n    \"tags\": [\n      { \"type\": \"tags\", \"id\": \"BJgxNfjoqN\" }\n    ],\n    \"sku_list_items\": [\n      { \"sku_list\": { \"id\": \"BbpjSNNkAZ\" } }\n    ]\n  }\n]","3,12",{"_modelApiKey":367,"icon":407,"copy":484,"color":370},"\u003Cp>You must include tags and SKU list items in the SKU data because the rules engine traverses these relationships during condition evaluation. Without them, matches will never fire.\u003C\u002Fp>\n",{"id":486,"copy":487,"_modelApiKey":374,"listStyle":375,"subtitle":488,"title":489,"darkTheme":11,"buttons":490,"sectionId":491,"color":370},"DdvDwLpDTNitOd0awU1M-w","\u003Cp>The \u003Ccode>\u002Fcheck\u003C\u002Fcode> endpoint accepts the following request body:\u003C\u002Fp>\n","Step 3","Calling the check endpoint",[],"step-3",{"_modelApiKey":422,"code":493,"showLineNumbers":11,"highlightLines":494,"language":438,"size":425},"{ \n  \"payload\": [\n\t  { ... }\n\t], \n\t\"rules\": [\n\t  { ... }\n\t] \n}","2,5",{"_modelApiKey":427,"copy":496,"listStyle":375,"darkTheme":11,"buttons":497,"color":370,"indent":11},"\u003Cp>Where:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>\u003Ccode>payload\u003C\u002Fcode> — represents the context the rules are evaluated against (in this case, the customer&#39;s current cart).\u003C\u002Fli>\n\u003Cli>\u003Ccode>rules\u003C\u002Fcode> — is the rules array extracted in \u003Cem>Step 1\u003C\u002Fem>.\u003C\u002Fli>\n\u003C\u002Ful>\n",[],{"_modelApiKey":427,"copy":499,"listStyle":375,"darkTheme":11,"buttons":500,"color":370,"indent":11},"\u003Ch3>How the loop works\u003C\u002Fh3>\n\n\u003Cp>For each rule in your array \u003Cem>(Step 1)\u003C\u002Fem>, build the cart payload by \u003Cstrong>injecting all candidate products\u003C\u002Fstrong> \u003Cem>(Step 2)\u003C\u002Fem> as additional line items. Set \u003Ccode>quantity: 1\u003C\u002Fcode> for each of them (you can adjust this value based on your business logic).\u003C\u002Fp>\n\n\u003Cp>Here is the complete request body for the first iteration (rule \u003Ccode>p0\u003C\u002Fcode>):\u003C\u002Fp>\n",[],{"_modelApiKey":422,"code":502,"showLineNumbers":11,"highlightLines":503,"language":438,"size":439},"{\n  \"payload\": [\n    {\n      \"order\": {\n        \"id\": \"oKkhYLlzgE\",\n        \"line_items\": [\n          {\n            \"quantity\": 1,\n            \"id\": \"gnYtPpKLeG\",\n            \"sku\": {\n              \"id\": \"anZtGpkLeP\",\n              \"code\": \"SKU0\"\n            }\n          },\n          {\n            \"quantity\": 1,\n            \"sku\": {\n              \"id\": \"DGjtgmdLjW\",\n              \"tags\": [\n                { \n\t\t\t\t\t\t\t\t  \"type\": \"tags\",\n\t\t\t\t\t\t\t\t\t\"id\": \"mJPnBfEezQ\" \n\t\t\t\t\t\t\t\t}\n              ],\n              \"sku_list_items\": [\n                { \n\t\t\t\t\t\t\t\t  \"sku_list\": { \"id\": \"BbpjSNNkAZ\" }\n\t\t\t\t\t\t\t\t}\n              ]\n            }\n          }\n        ]\n      }\n    }\n  ],\n  \"rules\": [\n    {\n      \"id\": \"p0\",\n      \"name\": \"Get 50% off if product has tag 'on-sale'\",\n      \"conditions\": [\n        {\n          \"field\": \"order.line_items.sku.tags.id\",\n          \"matcher\": \"array_match\",\n          \"value\": { \n\t\t\t\t\t  \"in_or\": [\"mJPnBfEezQ\"] \n\t\t\t\t\t},\n          \"group\": \"discountable_items\"\n        }\n      ],\n      \"actions\": [\n        {\n          \"type\": \"percentage\",\n          \"value\": 0.5,\n          \"selector\": \"order.line_items\",\n          \"groups\": [ \"discountable_items\" ]\n        }\n      ]\n    }\n  ]\n}","10,11,12,13,17,18,19,20,21,22,23,24,25,26,27,28,29",{"_modelApiKey":427,"copy":505,"listStyle":375,"darkTheme":11,"buttons":506,"color":370,"indent":11},"\u003Cp>The response will look like this:\u003C\u002Fp>\n",[],{"_modelApiKey":422,"code":508,"showLineNumbers":11,"highlightLines":509,"language":438,"size":439},"{\n  \"data\": [\n    {\n      \"id\": \"p0\",\n      \"name\": \"Get 50% off if product has tag 'on-sale'\",\n      \"priority\": 0,\n      \"match\": true,\n      \"conditions_logic\": \"and\",\n      \"conditions\": [\n        {\n          \"field\": \"order.line_items.sku.tags.id\",\n          \"matcher\": \"array_match\",\n          \"value\": { \"in_or\": [\"mJPnBfEezQ\"] },\n          \"group\": \"discountable_items\",\n          \"match\": true,\n          \"matches\": [\n            {\n              \"order\": \"oKkhYLlzgE\",\n              \"line\": \"items\",\n              \"sku\": \"DGjtgmdLjW\",\n              \"group\": \"discountable_items\"\n            }\n          ],\n          \"scope\": \"any\"\n        }\n      ],\n      \"actions\": [\n        {\n          \"resources\": [\n            {\n              \"resource_type\": \"line_items\",\n              \"id\": \"gnYtPpKLeG\",\n              \"group\": \"discountable_items\",\n              \"quantity\": 1,\n              \"value\": 0.5,\n              \"action_type\": \"percentage\"\n            }\n          ]\n        }\n      ]\n    }\n  ]\n}","7,15,16,17,18,19,20,21,22,23",{"_modelApiKey":367,"icon":511,"copy":512,"color":370},"check-circle","\u003Cp>The key field here is \u003Ccode>&quot;match&quot;: true\u003C\u002Fcode> at the rule level. This confirms that if the customer added SKU identified by the ID \u003Ccode>DGjtgmdLjW\u003C\u002Fcode> to their cart, the promotion \u003Ccode>p0\u003C\u002Fcode> would automatically apply.\u003C\u002Fp>\n",{"_modelApiKey":427,"copy":514,"listStyle":375,"darkTheme":11,"buttons":515,"color":370,"indent":11},"\u003Cp>Repeat the loop for each rule in the array from \u003Cem>Step 1\u003C\u002Fem>.\u003C\u002Fp>\n",[],{"_modelApiKey":427,"copy":517,"listStyle":375,"darkTheme":11,"buttons":518,"color":370,"indent":11},"\u003Ch3>What the customer sees\u003C\u002Fh3>\n\n\u003Cp>Once you&#39;ve identified rules with that match you candidate products, your frontend has everything it needs to display a contextual suggestion in the cart:\u003C\u002Fp>\n",[],{"_modelApiKey":397,"border":7,"caption":280,"image":520,"size":527,"darkTheme":11,"rounded":7,"color":370},{"url":521,"alt":522,"title":522,"width":523,"height":524,"format":290,"focalPoint":525,"customData":526},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1773309075-checkout-upsell.jpg","Checkout upsell",1920,1174,{"x":292,"y":292},{},"standard",{"_modelApiKey":427,"copy":529,"listStyle":375,"darkTheme":11,"buttons":530,"color":370,"indent":11},"\u003Cp>You already know which product to suggest (the SKU from the array in \u003Cem>Step 2\u003C\u002Fem> that triggered the match), and you already know the discount that will be applied (from the rule&#39;s action). No additional API calls are needed.\u003C\u002Fp>\n",[],{"_modelApiKey":427,"copy":532,"listStyle":533,"darkTheme":11,"buttons":534,"color":370,"indent":11},"\u003Ch3>Advanced possibilities\u003C\u002Fh3>\n\n\u003Cp>This is a minimal example with one rule and two candidate SKUs, but the pattern can be scaled easily:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>\u003Cstrong>\u003Cem>Multiple products and multiple rules\u003C\u002Fem>\u003C\u002Fstrong>---Iterate over all combinations and select the most advantageous promotion to surface.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Cem>Prioritization\u003C\u002Fem>\u003C\u002Fstrong>---If multiple rules match, show the one with the highest discount or the closest expiry date\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Cem>Customer personalization\u003C\u002Fem>\u003C\u002Fstrong>---Combine the \u003Ccode>upsell\u003C\u002Fcode> tag with customer-level conditions (e.g. segment, order history) for targeted suggestions.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Cem>A\u002FB testing\u003C\u002Fem>\u003C\u002Fstrong>---Use the check endpoint to simulate different promotional strategies without touching the live cart.\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Ch3>Try it out\u003C\u002Fh3>\n\n\u003Cp>If you want to start experimenting with advanced promotion logic, request a free trial period directly from your \u003Ca href=\"https:\u002F\u002Fdashboard.commercelayer.io\u002F\">Dashboard\u003C\u002Fa> in the \u003Cem>Promotions\u003C\u002Fem> app by clicking on \u003Cem>Flex promotion\u003C\u002Fem>. We&#39;ll help you get started with the Rules Engine and tailor it to your business needs.\u003C\u002Fp>\n","checkbox",[],{"_modelApiKey":397,"border":7,"caption":280,"image":536,"size":527,"darkTheme":11,"rounded":7,"color":370},{"url":537,"alt":538,"title":538,"width":289,"height":539,"format":290,"focalPoint":540,"customData":541},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1773247961-meet-the-promotion-builder.jpg","Promotion builder upgrade",856,{"x":292,"y":292},{},[543,544,546,548,550,552,554,556,558,560,562,564,566,568,570,572,574],{"attributes":303,"tag":304,"content":305},{"attributes":545,"tag":309,"content":303},{"property":308,"content":305},{"attributes":547,"tag":309,"content":303},{"name":312,"content":305},{"attributes":549,"tag":309,"content":303},{"name":315,"content":316},{"attributes":551,"tag":309,"content":303},{"property":319,"content":316},{"attributes":553,"tag":309,"content":303},{"name":322,"content":316},{"attributes":555,"tag":309,"content":303},{"property":325,"content":326},{"attributes":557,"tag":309,"content":303},{"property":329,"content":330},{"attributes":559,"tag":309,"content":303},{"property":333,"content":334},{"attributes":561,"tag":309,"content":303},{"name":337,"content":326},{"attributes":563,"tag":309,"content":303},{"property":340,"content":341},{"attributes":565,"tag":309,"content":303},{"property":344,"content":345},{"attributes":567,"tag":309,"content":303},{"property":348,"content":349},{"attributes":569,"tag":309,"content":303},{"property":352,"content":353},{"attributes":571,"tag":309,"content":303},{"property":356,"content":280},{"attributes":573,"tag":309,"content":303},{"name":359,"content":360},{"attributes":575,"tag":309,"content":303},{"name":363,"content":364},[577],{"name":285,"picture":578},{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":579,"customData":580},{"x":292,"y":292},{},1791534732192]