get('Magento\SalesRule\Model\RuleFactory'); $salesRule = $salesRuleFactory->create(); $salesRuleId = $objectManager->get('Magento\Framework\Registry') ->registry('Magento/Checkout/_file/discount_10percent'); $salesRule->load($salesRuleId); $couponCode = $salesRule->getPrimaryCoupon()->getCode(); $quote->setCouponCode(trim($couponCode)); $quote->collectTotals()->save();