[{"data":1,"prerenderedAt":508},["ShallowReactive",2],{"bootstrap":3,"blog-time-based-promotions-birthday-coupons-and-spend-limits":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","payment-api-redesigned","Introducing our new Payments API. For humans and agents.","\u003Cp>Introducing our new Payments API. For humans and agents.\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":469,"authors":503},{"text":279,"isExternal":11,"url":280,"link":281},"Birthday coupons and spend limits with Commerce Layer.","",{"_modelApiKey":212,"slug":282},"time-based-promotions-birthday-coupons-and-spend-limits","February 24, 2026",{"name":285,"picture":286},"Sara Bonechi",{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":291,"customData":293},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1764784884-sara.jpg","Sara Bonechi avatar",1280,"jpg",{"x":292,"y":292},0.5,{},[],"cake","Learn how to use Commerce Layer’s Rules Engine to create birthday discounts, limit eligibility with customer metadata, and manage dynamic spend thresholds with precision.",{"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","Birthday coupons and spend limits 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","Turn customer data into personalized promotions with time-based rules and spend thresholds in Commerce Layer.",{"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\u002F1770892215-birthday-coupons.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-02-24T14:43:14Z",{"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,372,379,382,388,391,399,402,409,411,415,418,421,424,427,430,440,447,449,452,455,457,460,463,466],{"_modelApiKey":367,"copy":368,"listStyle":369,"darkTheme":11,"buttons":370,"color":371,"indent":7},"wysiwyg","\u003Cp>It’s common practice to reward customers with a birthday coupon voucher. These coupons are usually generated ahead of time and can be redeemed only within a predefined validity window (for example: the birthday month, the exact birthday date, or a few days around it).\u003C\u002Fp>\n\n\u003Cp>Below, we outline a couple of approaches to manage this use case using the Commerce Layer \u003Cstrong>Rules Engine\u003C\u002Fstrong>.\u003C\u002Fp>\n","directional",[],"red",{"_modelApiKey":373,"title":374,"preTitle":375,"linkText":59,"darkTheme":11,"link":376},"link_block","Date-based dynamic values","Rules Engine",{"_modelApiKey":203,"text":377,"label":280,"subtitle":280,"icon":280,"isExternal":7,"url":378,"link":303,"anchor":280,"openForm":11,"form":303,"htmlClassNames":280},"Read the docs","https:\u002F\u002Fdocs.commercelayer.io\u002Frules-engine\u002Fconditions\u002Fdynamic-values#date-based-values",{"_modelApiKey":367,"copy":380,"listStyle":369,"darkTheme":11,"buttons":381,"color":371,"indent":11},"\u003Ch3>Leverage customer metadata fields or tags\u003C\u002Fh3>\n\n\u003Cp>As you know, Commerce Layer is not a CRM. However, in the \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fcore\u002Fapi-reference\u002Fcustomers\">customers\u003C\u002Fa> resource, you can access every customer who has initiated at least one order by providing an email address.\u003C\u002Fp>\n\n\u003Cp>In Commerce Layer, customers are primarily identified by their email address and enriched with a set of attributes, including their order-based status:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>\u003Cstrong>Prospect\u003C\u002Fstrong> — no orders\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Acquired\u003C\u002Fstrong> — one order\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Repeat\u003C\u002Fstrong> — more than one order\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Cp>These values are automatically calculated by Commerce Layer. Customers also have a registration status (\u003Cem>registered\u003C\u002Fem> or \u003Cem>guest\u003C\u002Fem>) and fields that help link customers to external CRM systems, such as \u003Ccode>profile_id\u003C\u002Fcode>, which can be used to uniquely identify a customer across connected services.\u003C\u002Fp>\n\n\u003Cp>You can also rely on \u003Cstrong>metadata\u003C\u002Fstrong>, which are customizable fields designed to store additional custom information.\u003C\u002Fp>\n\n\u003Cp>The Rules Engine can leverage on any of the fields listed above to activate promotions: you can create discounts for registered customers only, or for customers that have never placed an order before or use customer metadata and customer tags.\u003C\u002Fp>\n\n\u003Cp>For example:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>If you store a customer’s first and last name as metadata, you can create a promotion that applies only to customers whose name is &quot;John&quot;.\u003C\u002Fli>\n\u003Cli>You can use tags to segment customers into tiers such as &quot;bronze&quot;, &quot;silver&quot;, or &quot;gold&quot;, and apply different discount percentages based on the assigned tag.\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Cp>Similarly, you can store a customer’s birthday date as metadata and configure a promotion that triggers only when an order is placed during the matching period.\u003C\u002Fp>\n\n\u003Cp>Below is an example about how to set the \u003Ccode>metadata\u003C\u002Fcode> field for this purpose:\u003C\u002Fp>\n",[],{"_modelApiKey":383,"code":384,"showLineNumbers":11,"highlightLines":385,"language":386,"size":387},"code_block","{\n  \"id\": \"OopZhmqLlQ\",\n  \"type\": \"customers\",\n  \"email\": \"john.doe@example.com\",\n  ...\n  \"metadata\": { \"birthday_date\": \"1978-02-28\"},\n  ...\n}","6","json","Wide",{"_modelApiKey":367,"copy":389,"listStyle":369,"darkTheme":11,"buttons":390,"color":371,"indent":11},"\u003Ch3>Building a birthday promotion\u003C\u002Fh3>\n\n\u003Cp>In the following examples, we created some birthday flex promotions that apply a \u003Cstrong>fixed discount of 5 EUR\u003C\u002Fstrong> only if the customer places an order within a defined period around their birthday. You can adjust the validity logic to apply only on the exact month or day, or within a custom window (e.g., 3 days before and 3 days after), depending on your business requirements.\u003C\u002Fp>\n",[],{"id":392,"copy":393,"_modelApiKey":394,"listStyle":369,"subtitle":395,"title":396,"darkTheme":11,"buttons":397,"sectionId":398,"color":371},"bCd_TmaRSveiBBNn55Bk-A","\u003Cp>This is the JSON rule that triggers the promotion only if the customer places and order within the month of their birthday:\u003C\u002Fp>\n","wysiwyg_section","Example 1","Promo valid only on the exact month",[],"example-1",{"_modelApiKey":383,"code":400,"showLineNumbers":11,"highlightLines":401,"language":386,"size":387},"{\n  \"rules\": [\n    {\n      \"id\": \"promo-birthday-month-today\",\n      \"name\": \"5 EURO discount on customer birthday month (today)\",\n\t\t\t\"conditions\": [\n        {\n          \"field\": \"order.customer.metadata.birthday_date\",\n          \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\",\n          \"value\": \"{{month(today)}}\",\n          \"matcher\": \"eq\"\n        }\n      ],\n      \"actions\": [\n        {\n          \"type\": \"fixed_amount\",\n          \"value\": 500,\n          \"groups\": [ \"d457b413-0070-4696-8091-bb428ac67e87\" ],\n          \"selector\": \"order\"\n        }\n      ]\n    }\n  ]\n}","10",{"id":403,"copy":404,"_modelApiKey":394,"listStyle":369,"subtitle":405,"title":406,"darkTheme":11,"buttons":407,"sectionId":408,"color":371},"WZfJXzM5SWit2aFDMywcWg","\u003Cp>If you want to restrict the promotion to the customer’s exact birthday day, you can adjust the condition as follows:\u003C\u002Fp>\n","Example 2","Promo valid only on the exact day",[],"example-2",{"_modelApiKey":383,"code":410,"showLineNumbers":11,"highlightLines":401,"language":386,"size":387},"{\n  \"rules\": [\n    {\n      \"id\": \"promo-birthday-today\",\n      \"name\": \"5 EURO discount on customer birthday (today)\",\n\t\t\t\"conditions\": [\n        {\n          \"field\": \"order.customer.metadata.birthday_date\",\n          \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\",\n          \"value\": \"{{birthday}}\",\n          \"matcher\": \"eq\"\n        }\n      ],\n      \"actions\": [\n        {\n          \"type\": \"fixed_amount\",\n          \"value\": 500,\n          \"groups\": [ \"d457b413-0070-4696-8091-bb428ac67e87\" ],\n          \"selector\": \"order\"\n        }\n      ]\n    }\n  ]\n}",{"_modelApiKey":412,"icon":413,"copy":414,"color":371},"banner","check-circle","\u003Cp>The rule itself is straightforward: it compares the customer’s birthday date stored in the metadata field with the order date.\u003C\u002Fp>\n",{"_modelApiKey":367,"copy":416,"listStyle":369,"darkTheme":11,"buttons":417,"color":371,"indent":11},"\u003Cp>If the customer in the example (born on February 28th) tries to use the coupon on February 10th, the promotion won’t match. This is visible in the \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Frules-engine\u002Fcheck-and-validation\">order checkpoint\u003C\u002Fa> response:\u003C\u002Fp>\n",[],{"_modelApiKey":383,"code":419,"showLineNumbers":11,"highlightLines":420,"language":386,"size":387},"{\n  \"id\": \"promo-birthday-today\",\n  \"name\": \"5 EURO discount on customer birthday (today)\",\n  \"priority\": 0,\n  \"match\": false,\n  \"conditions_logic\": \"and\",\n  \"conditions\": [\n    {\n      \"field\": \"order.customer.metadata.birthday_date\",\n      \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\",\n      \"value\": \"{birthday}\",\n      \"matcher\": \"eq\",\n      \"match\": false,\n      \"matches\": [],\n      \"scope\": \"any\"\n    }\n  ],\n  \"actions\": []\n}","5,13,14,18",{"_modelApiKey":367,"copy":422,"listStyle":369,"darkTheme":11,"buttons":423,"color":371,"indent":11},"\u003Cp>On the customer’s actual birthday date, the promotion matches and the discount is applied:\u003C\u002Fp>\n",[],{"_modelApiKey":383,"code":425,"showLineNumbers":11,"highlightLines":426,"language":386,"size":387},"{\n  \"id\": \"promo-birthday-today\",\n  \"name\": \"5 EURO discount on customer birthday (today)\",\n  \"priority\": 0,\n  \"match\": true,\n  \"conditions_logic\": \"and\",\n  \"conditions\": [\n    {\n      \"field\": \"order.customer.metadata.birthday_date\",\n      \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\",\n      \"value\": \"{birthday}\",\n      \"matcher\": \"eq\",\n      \"match\": true,\n      \"matches\": [\n        {\n          \"order\": \"Nlalhbbvom\",\n          \"customer\": \"OopZhmqLlQ\",\n          \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\"\n        }\n      ],\n      \"scope\": \"any\"\n    }\n  ],\n  \"actions\": [\n    {\n      \"resources\": [\n        {\n          \"resource_type\": \"orders\",\n          \"id\": \"Nlalhbbvom\",\n          \"group\": \"d457b413-0070-4696-8091-bb428ac67e87\",\n          \"quantity\": null,\n          \"value\": 500,\n          \"action_type\": \"fixed_amount\"\n        }\n      ]\n    }\n  ]\n}","5,12,13,14,15,16,17,18,19,32,33",{"_modelApiKey":367,"copy":428,"listStyle":369,"darkTheme":11,"buttons":429,"color":371,"indent":11},"\u003Cp>The promotion is activated via a coupon code \u003Ccode>BIRTHDAY-PROMO\u003C\u002Fcode> and can be redeemed only once per customer:\u003C\u002Fp>\n",[],{"_modelApiKey":431,"border":7,"caption":280,"image":432,"size":439,"darkTheme":11,"rounded":7,"color":371},"image_block",{"url":433,"alt":434,"title":434,"width":435,"height":436,"format":290,"focalPoint":437,"customData":438},"https:\u002F\u002Fwww.datocms-assets.com\u002F35053\u002F1770994803-birthday-promo-dashboard.jpg","Birthday promo coupon",1920,1287,{"x":292,"y":292},{},"wide",{"id":441,"copy":442,"_modelApiKey":394,"listStyle":369,"subtitle":443,"title":444,"darkTheme":11,"buttons":445,"sectionId":446,"color":371},"UYZIqI6HQEC2valM9C381g","\u003Cp>Assume you want to mark a milestone occasion — such as a customer’s 50th birthday — by offering a 50% discount. The discount should be valid during a specific \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Frules-engine\u002Fconditions\u002Fdynamic-values#date-ranges\">time window\u003C\u002Fa>: from seven days before to seven days after the customer’s 50th birthday.\u003C\u002Fp>\n\n\u003Cp>Below is an example about how to set the \u003Ccode>metadata\u003C\u002Fcode> field for this purpose:\u003C\u002Fp>\n","Example 3","Promo valid only on a custom date range",[],"example-3",{"_modelApiKey":383,"code":448,"showLineNumbers":11,"highlightLines":385,"language":386,"size":387},"{\n  \"id\": \"OopZhmqLlQ\",\n  \"type\": \"customers\",\n  \"email\": \"john.doe@example.com\",\n  ...\n  \"metadata\": { \"50_birthday\": \"2026-02-23\"},\n  ...\n}",{"_modelApiKey":367,"copy":450,"listStyle":369,"darkTheme":11,"buttons":451,"color":371,"indent":11},"\u003Cp>This is the JSON rule that triggers the desired promotion:\u003C\u002Fp>\n",[],{"_modelApiKey":383,"code":453,"showLineNumbers":11,"highlightLines":454,"language":386,"size":387},"{\n  \"rules\": [\n    {\n      \"id\": \"promo-50-birthday\",\n      \"name\": \"50% on 50th birthday\",\n\t\t\t\"conditions\": [\n        {\n          \"field\": \"order.customer.metadata.50_birthday\",\n          \"matcher\": \"gteq_lteq\",\n          \"group\": \"ffaba434-a1fa-4654-ba21-4e80f183e959\",\n          \"value\": \"{{range(today, 7.days)}}\"\n        }\n      ],\n      \"actions\": [\n        {\n          \"type\": \"percentage\",\n          \"selector\": \"order.line_items\",\n          \"groups\": [ \"ffaba434-a1fa-4654-ba21-4e80f183e959\" ],\n          \"value\": 0.5\n        }\n      ]\n    }\n  ]\n}","11",{"_modelApiKey":412,"icon":413,"copy":456,"color":371},"\u003Cp>In this setup, the rule evaluates the value stored in the customer’s metadata against the order date. The promotion is automatically applied only if the order is placed within seven days before or after the specified 50-birthday date.\u003C\u002Fp>\n",{"_modelApiKey":367,"copy":458,"listStyle":369,"darkTheme":11,"buttons":459,"color":371,"indent":11},"\u003Ch3>Discounts with spend limits\u003C\u002Fh3>\n\n\u003Cp>Using the same approach, you can rely on customer metadata to define spending thresholds that determine whether a customer can continue benefiting from a promotion.\u003C\u002Fp>\n\n\u003Cp>For example, you can store a \u003Ccode>total_spent\u003C\u002Fcode> value inside customer metadata. This field should be updated every time an order is approved or canceled by an external process, using the Commerce Layer \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fmetrics\">Metrics API\u003C\u002Fa> to compute the customer’s total spend.\u003C\u002Fp>\n\n\u003Cp>Here&#39;s an example query to the \u003Ccode>\u002Fstats\u003C\u002Fcode> \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Fmetrics\u002Fgetting-started\u002Fqueries\u002Fstats\">endpoint\u003C\u002Fa>:\u003C\u002Fp>\n",[],{"_modelApiKey":383,"code":461,"showLineNumbers":11,"highlightLines":462,"language":386,"size":387},"{\n  \"stats\": {\n    \"field\": \"order.total_amount_with_taxes\",\n    \"operator\": \"sum\"\n  },\n  \"filter\": {\n    \"order\": {\n      \"mode\": \"test\",\n      \"date_from\": \"2025-01-01T00:00:00Z\",\n      \"date_to\": \"2026-12-23T23:59:59Z\",\n      \"date_field\": \"current_date\",\n      \"returned\": false,\n      \"statuses\": {\n        \"in\": [ \"approved\" ]\n      },\n      \"currency_codes\": {\n        \"in\": [ \"EUR\" ]\n      }\n    },\n    \"customer\": {\n      \"emails\": {\n        \"in\": [ \"\u003CCUSTOMER_EMAIL_HERE>\" ]\n      }\n    },\n    \"meta\": {\n      \"payload\": true\n    }\n  }\n}","2,3,4,5,13,14,15,16,17,18,21,22,23",{"_modelApiKey":367,"copy":464,"listStyle":369,"darkTheme":11,"buttons":465,"color":371,"indent":11},"\u003Cp>This way, \u003Ccode>customer.metadata.total_spent\u003C\u002Fcode> can be kept updated every time the customer places a new order.\u003C\u002Fp>\n\n\u003Cp>At this point, you can extend your promotion by adding a condition that checks whether \u003Ccode>order.customer.metadata.total_spent\u003C\u002Fcode> is lower than a defined threshold (e.g., \u003Cstrong>100 EUR\u003C\u002Fstrong>). If the metadata value exceeds that limit, the promotion will no longer match and the discount will not be applied.\u003C\u002Fp>\n\n\u003Cp>For example:\u003C\u002Fp>\n\n\u003Cul>\n\u003Cli>If the customer’s total spend reaches \u003Cstrong>100 EUR\u003C\u002Fstrong>, the promotion won’t apply.\u003C\u002Fli>\n\u003Cli>If the customer’s total spend is lowered to \u003Cstrong>1 EUR\u003C\u002Fstrong>, the promotion will match and the discount will be calculated correctly.\u003C\u002Fli>\n\u003C\u002Ful>\n",[],{"_modelApiKey":367,"copy":467,"listStyle":369,"darkTheme":11,"buttons":468,"color":371,"indent":11},"\u003Ch3>Try It Out\u003C\u002Fh3>\n\n\u003Cp>If you want to start experimenting with advanced promotion logic, request a free trial directly from your \u003Ca href=\"https:\u002F\u002Fdashboard.commercelayer.io\u002Fsign_in\">Dashboard\u003C\u002Fa> in the Promotions app.\u003C\u002Fp>\n\n\u003Cp>We’ll help you get started with the \u003Ca href=\"https:\u002F\u002Fdocs.commercelayer.io\u002Frules-engine\">Rules Engine\u003C\u002Fa> and tailor it to your business needs.\u003C\u002Fp>\n",[],[470,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499,501],{"attributes":303,"tag":304,"content":305},{"attributes":472,"tag":309,"content":303},{"property":308,"content":305},{"attributes":474,"tag":309,"content":303},{"name":312,"content":305},{"attributes":476,"tag":309,"content":303},{"name":315,"content":316},{"attributes":478,"tag":309,"content":303},{"property":319,"content":316},{"attributes":480,"tag":309,"content":303},{"name":322,"content":316},{"attributes":482,"tag":309,"content":303},{"property":325,"content":326},{"attributes":484,"tag":309,"content":303},{"property":329,"content":330},{"attributes":486,"tag":309,"content":303},{"property":333,"content":334},{"attributes":488,"tag":309,"content":303},{"name":337,"content":326},{"attributes":490,"tag":309,"content":303},{"property":340,"content":341},{"attributes":492,"tag":309,"content":303},{"property":344,"content":345},{"attributes":494,"tag":309,"content":303},{"property":348,"content":349},{"attributes":496,"tag":309,"content":303},{"property":352,"content":353},{"attributes":498,"tag":309,"content":303},{"property":356,"content":280},{"attributes":500,"tag":309,"content":303},{"name":359,"content":360},{"attributes":502,"tag":309,"content":303},{"name":363,"content":364},[504],{"name":285,"picture":505},{"url":287,"alt":288,"title":288,"width":289,"height":289,"format":290,"focalPoint":506,"customData":507},{"x":292,"y":292},{},1790330001238]