public function PromotionUsage::loadByCoupon in Commerce Core 8.2
Loads the usage for the given coupon.
The optional $mail parameter can be used to restrict the usage count to a specific customer email.
Parameters
\Drupal\commerce_promotion\Entity\CouponInterface $coupon: The coupon.
string $mail: (Optional) The customer email.
Return value
int The usage.
Overrides PromotionUsageInterface::loadByCoupon
File
- modules/
promotion/ src/ PromotionUsage.php, line 83
Class
Namespace
Drupal\commerce_promotionCode
public function loadByCoupon(CouponInterface $coupon, $mail = NULL) {
$usages = $this
->loadMultipleByCoupon([
$coupon,
], $mail);
return $usages[$coupon
->id()];
}