CouponStorage.php in Commerce Core 8.2
File
modules/promotion/src/CouponStorage.php
View source
<?php
namespace Drupal\commerce_promotion;
use Drupal\commerce\CommerceContentEntityStorage;
use Drupal\commerce_promotion\Entity\PromotionInterface;
class CouponStorage extends CommerceContentEntityStorage implements CouponStorageInterface {
public function loadEnabledByCode($code) {
$coupons = $this
->loadByProperties([
'code' => $code,
'status' => TRUE,
]);
return reset($coupons);
}
public function loadMultipleByPromotion(PromotionInterface $promotion) {
return $this
->loadByProperties([
'promotion_id' => $promotion
->id(),
]);
}
}