You are here

public function Promotion::addCoupon in Commerce Core 8.2

Adds a coupon.

Parameters

\Drupal\commerce_promotion\Entity\CouponInterface $coupon: The coupon.

Return value

$this

Overrides PromotionInterface::addCoupon

File

modules/promotion/src/Entity/Promotion.php, line 352

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function addCoupon(CouponInterface $coupon) {
  if (!$this
    ->hasCoupon($coupon)) {
    $this
      ->get('coupons')
      ->appendItem($coupon);
  }
  return $this;
}