You are here

public function Promotion::setOffer in Commerce Core 8.2

Sets the offer.

Parameters

\Drupal\commerce_promotion\Plugin\Commerce\PromotionOffer\PromotionOfferInterface $offer: The offer.

Return value

$this

Overrides PromotionInterface::setOffer

File

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

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function setOffer(PromotionOfferInterface $offer) {
  $this
    ->set('offer', [
    'target_plugin_id' => $offer
      ->getPluginId(),
    'target_plugin_configuration' => $offer
      ->getConfiguration(),
  ]);
  return $this;
}