Can a coupon be programmatically added to an order using the add to cart subscriber? I'm attempting to add a coupon to an order when an item is added to the cart.  I've added an event subscriber for commerce_cart.entity.add. Within the subscriber, I use $to_apply-&gt;getPromotion()-&gt;apply($event-&gt;getCart());.

This does end up in Promotion::apply() and does call $offer-&gt;apply(), but the coupon doesn't seem to actually get applied.  I've tried to see if, once we arrive at /checkout/{order_id}, the promotions/coupons are reset. AFAICT, they are not.

I have confirmed that I can manually apply the coupon once on /checkout/{order_id}.

What am I missing?
Got an answer via Slack.  You only need to update the OrderInteface and set the coupons property, then resave the order.  PromotionOrderProcessor handles applying the coupon to the order. 

Something like this should work within your event subscriber:

  /** @var \Drupal\commerce_promotion\Entity\Coupon $to_apply */
  $to_apply = $coupon
  /** @var OrderInterface $cart */
  $cart = $event-&gt;getCart();
  $cart-&gt;set('coupons', $to_apply);
  $cart-&gt;save();