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\EntityCode
public function addCoupon(CouponInterface $coupon) {
if (!$this
->hasCoupon($coupon)) {
$this
->get('coupons')
->appendItem($coupon);
}
return $this;
}