You are here

public function Promotion::removeCoupon in Commerce Core 8.2

Removes a coupon.

Parameters

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

Return value

$this

Overrides PromotionInterface::removeCoupon

File

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

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function removeCoupon(CouponInterface $coupon) {
  $index = $this
    ->getCouponIndex($coupon);
  if ($index !== FALSE) {
    $this
      ->get('coupons')
      ->offsetUnset($index);
  }
  return $this;
}