You are here

public function Promotion::hasCoupon in Commerce Core 8.2

Checks whether the promotion has a given coupon.

Parameters

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

Return value

bool TRUE if the coupon was found, FALSE otherwise.

Overrides PromotionInterface::hasCoupon

1 call to Promotion::hasCoupon()
Promotion::addCoupon in modules/promotion/src/Entity/Promotion.php
Adds a coupon.

File

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

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function hasCoupon(CouponInterface $coupon) {
  return in_array($coupon
    ->id(), $this
    ->getCouponIds());
}