{"data":{"id":"magento2-40653","source":"github-pr","sourceRef":"magento/magento2#40653","title":"Cart Price Rule with limited usage is not applied when editing an existing order in Admin (e.g. \"Uses per Customer = 1\")","pr":{"number":40653,"url":"https://github.com/magento/magento2/pull/40653","author":"lbajsarowicz","mergedAt":"2026-06-25T11:59:09Z","mergeCommit":"e90c2fedeaab602321c1a83183efea2f1716c7af","headCommit":"8b5e33902651dcf214f79a24a6f660328b17565f","baseRef":"2.4-develop","diffSha256":"7dfe892fe0b05d6918588be25474148b7a2196a6da6d0408ba387d5087e6c12b"},"issues":[{"number":40624,"url":"https://github.com/magento/magento2/issues/40624","title":"Cart Price Rule with limited usage is not applied when editing an existing order in Admin (e.g. \"Uses per Customer = 1\")","labels":["Area: Order","Component: SalesRule","Issue: Confirmed","Priority: P2","Progress: PR Created","Progress: done","Reported on 2.4.8-p3","Reproduced on 2.4.x"],"kind":"human"}],"fixedIn":null,"containingTags":[],"reportedOn":"2.4.8-p3","codeMatch":{"2.4.6":"file-missing","2.4.6-p1":"file-missing","2.4.6-p2":"file-missing","2.4.6-p3":"file-missing","2.4.6-p4":"file-missing","2.4.6-p5":"file-missing","2.4.6-p6":"file-missing","2.4.6-p7":"file-missing","2.4.6-p8":"file-missing","2.4.6-p9":"file-missing","2.4.6-p10":"file-missing","2.4.6-p11":"file-missing","2.4.6-p12":"file-missing","2.4.6-p13":"file-missing","2.4.6-p14":"file-missing","2.4.6-p15":"file-missing","2.4.7":"conflict","2.4.7-p1":"conflict","2.4.7-p2":"conflict","2.4.7-p3":"conflict","2.4.7-p4":"conflict","2.4.7-p5":"conflict","2.4.7-p6":"conflict","2.4.7-p7":"conflict","2.4.7-p8":"conflict","2.4.7-p9":"conflict","2.4.7-p10":"conflict","2.4.8":"conflict","2.4.8-p1":"conflict","2.4.8-p2":"conflict","2.4.8-p3":"conflict","2.4.8-p4":"conflict","2.4.8-p5":"conflict","2.4.9":"clean"},"affectedVersions":["2.4.9"],"components":["magento/module-sales","magento/module-sales-rule"],"files":[{"path":"app/code/Magento/Sales/Model/AdminOrder/Create.php","change":"modified","package":"magento/module-sales"},{"path":"app/code/Magento/SalesRule/Model/Utility.php","change":"modified","package":"magento/module-sales-rule"},{"path":"app/code/Magento/SalesRule/Model/ValidateCoupon.php","change":"modified","package":"magento/module-sales-rule"}],"stripped":{"tests":["app/code/Magento/SalesRule/Test/Mftf/Test/AdminEditOrderPreservesCartPriceRuleWithUsageLimitTest.xml","app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php","dev/tests/integration/testsuite/Magento/SalesRule/Model/CouponUsageLimitOrderEditTest.php"],"docs":[],"outsideCode":[]},"linesChanged":56,"mergeBatched":false,"excluded":null,"sections":{"description":"The discount is not applied when editing the order in the admin panel.\nMagento re-validates the rule usage and blocks the discount because the usage limit has already been reached.","stepsToReproduce":"1. In the Admin Panel, create a Cart Price Rule with:\n- A discount (e.g. 50%)\n- Limited usage configured (e.g. **Uses per Customer = 1**)\n\n<img width=\"1455\" height=\"897\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/8e8bf39e-aead-435a-9d35-7168388dd9c2\" />\n\n2. On the storefront, place an order as a customer using this rule until **the usage limit is reached.**\n3. In the Admin Panel, navigate to Sales → Orders.\n4. Open the order that was placed using the discount.\n5. Click Edit.\n\n<img width=\"1572\" height=\"873\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/1d714f13-ae91-4d72-b307-8e68068a6d8f\" />\n\n6. Modify the order (e.g. change product quantity or update items).\n7. Check whether the discount is applied to the edited order.\n\n<img width=\"1579\" height=\"861\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/1cb29120-f062-4a9a-a8bd-ed8f1bd163fb\" />","expectedResult":"The discount should remain applied when editing the order, since it is part of the same order and should preserve previously applied pricing rules regardless of usage limits.","actualResult":"The discount is not applied when editing the order in the admin panel.\nMagento re-validates the rule usage and blocks the discount because the usage limit has already been reached.\n\n<img width=\"1579\" height=\"861\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/1cb29120-f062-4a9a-a8bd-ed8f1bd163fb\" />","source":"issue"},"signatures":[],"labels":{"area":["Order"],"component":["SalesRule"],"priority":"P2","severity":null,"reportedOn":["2.4.8-p3"]},"categories":["Order/Checkout","Price/Tax"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"58a5a8d90c932c7324993cefbfed9c85d35e2cefeb41451cb145bd50ff0e8893","isBugfix":0.9825,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.9589,"feature":0.0076,"refactor":0.0143,"tests_only":0.0102,"docs_only":0.0039,"dependency":0.0051},"confidence":0.9039},"scope":{"score":0.7766,"probabilities":{"0":0.447,"1":0.3295,"2":0.2235},"confidence":0.0375},"risk":{"score":1.3169,"probabilities":{"0":0.2234,"1":0.2363,"2":0.5403},"confidence":0.0965},"area":{"choice":"checkout","probabilities":{"catalog":0.0122,"checkout":0.7482,"customer":0.0115,"admin":0.1551,"graphql_api":0.0066,"framework":0.0189,"frontend":0.0092,"other":0.0383},"confidence":0.5269},"securityRelevant":0.01,"reportedVersion":{"choice":"2.4.8-p3","probabilities":{"2.4.0":0.0023,"2.4.0-p1":0.0026,"2.4.1":0.0024,"2.4.1-p1":0.0027,"2.4.2":0.0025,"2.4.2-p1":0.0029,"2.4.2-p2":0.0032,"2.4.3":0.0024,"2.4.3-p1":0.0029,"2.4.3-p2":0.0033,"2.4.3-p3":0.0032,"2.4.4":0.0025,"2.4.4-p1":0.0028,"2.4.4-p10":0.0032,"2.4.4-p11":0.0035,"2.4.4-p12":0.0035,"2.4.4-p13":0.0037,"2.4.4-p14":0.0039,"2.4.4-p15":0.0033,"2.4.4-p16":0.0031,"2.4.4-p17":0.0031,"2.4.4-p18":0.0032,"2.4.4-p2":0.0026,"2.4.4-p3":0.0025,"2.4.4-p4":0.0024,"2.4.4-p5":0.0026,"2.4.4-p6":0.0028,"2.4.4-p7":0.0028,"2.4.4-p8":0.0034,"2.4.4-p9":0.0029,"2.4.5":0.0028,"2.4.5-p1":0.0028,"2.4.5-p10":0.0029,"2.4.5-p11":0.0032,"2.4.5-p12":0.0044,"2.4.5-p13":0.0035,"2.4.5-p14":0.0034,"2.4.5-p15":0.0031,"2.4.5-p16":0.003,"2.4.5-p17":0.0033,"2.4.5-p2":0.0032,"2.4.5-p3":0.0033,"2.4.5-p4":0.0032,"2.4.5-p5":0.0033,"2.4.5-p6":0.0036,"2.4.5-p7":0.0035,"2.4.5-p8":0.0042,"2.4.5-p9":0.0028,"2.4.6":0.0036,"2.4.6-p1":0.004,"2.4.6-p10":0.0046,"2.4.6-p11":0.005,"2.4.6-p12":0.0052,"2.4.6-p13":0.0049,"2.4.6-p14":0.0051,"2.4.6-p15":0.0043,"2.4.6-p2":0.0036,"2.4.6-p3":0.0043,"2.4.6-p4":0.0049,"2.4.6-p5":0.0046,"2.4.6-p6":0.0048,"2.4.6-p7":0.0047,"2.4.6-p8":0.0044,"2.4.6-p9":0.0032,"2.4.7":0.0046,"2.4.7-p1":0.0044,"2.4.7-p10":0.0049,"2.4.7-p2":0.0037,"2.4.7-p3":0.0059,"2.4.7-p4":0.007,"2.4.7-p5":0.0053,"2.4.7-p6":0.0074,"2.4.7-p7":0.0049,"2.4.7-p8":0.0048,"2.4.7-p9":0.0031,"2.4.8":0.0236,"2.4.8-p1":0.0048,"2.4.8-p2":0.0152,"2.4.8-p3":0.6357,"2.4.8-p4":0.017,"2.4.8-p5":0.0155,"2.4.9":0.0093,"unspecified":0.004},"confidence":0.3994},"backportWorthy":{"score":1.5887,"probabilities":{"0":0.0624,"1":0.2865,"2":0.6511},"confidence":0.2649}},"curated":{"title":"Fixes cart price rule discount being dropped when editing an order in admin","description":"When a Cart Price Rule with limited usage, such as Uses per Customer = 1, was applied to an order and the admin edited that order, the discount was removed because rule usage was validated again on the new quote. AdminOrder Create now passes the original order applied rule ids to the quote, except on reorder, and Utility::canProcessRule() and ValidateCoupon offset the usage by 1 for these rules.","categories":["Order/Checkout","Price/Tax"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":{"2.4.9":{"before":"fail","after":"fail","adapted":false,"runAt":"2026-10-06T09:33:40.541Z","releaseCommit":"755e34dd689021c5165db9d35ecff74f7dc51527","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:33:40.541Z"},"integration":{"before":"fail","after":"fail","runAt":"2026-10-06T09:33:40.541Z"}}}}},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-40653 details"}