Coupon Code Programmatically: Magento 2 Get

public function __construct(CollectionFactory $couponCollectionFactory)

use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; public function getCouponCodesFromOrders(CollectionFactory $orderCollectionFactory, array $orderIds) magento 2 get coupon code programmatically

public function fromOrder(int $orderId): ?string ?php namespace YourNamespace\YourModule\Model

<?php namespace YourNamespace\YourModule\Model; use Magento\SalesRule\Model\ResourceModel\Coupon\CollectionFactory; magento 2 get coupon code programmatically

If you need to know which coupon affected a specific cart item (useful for per‑item discount debugging).

class GetCouponFromQuote

Open Menu
Adult Game Reviews