function commerce_coupon_coupon_has_discount in Commerce Coupon 7.2
Determine whether a coupon has a particular discount.
Parameters
EntityDrupalWrapper $coupon_wrapper: The coupon to check.
string $discount_name: The discount name to check for.
Return value
void|bool Whether or not the coupon references a particular discount.
1 call to commerce_coupon_coupon_has_discount()
- commerce_coupon_form_attach_coupons in ./
commerce_coupon.module - Form submit callback: save a coupon from the discount UI.
File
- ./
commerce_coupon.module, line 1770 - Provides coupon functionality for Drupal Commerce.
Code
function commerce_coupon_coupon_has_discount(EntityDrupalWrapper $coupon_wrapper, $discount_name) {
if ($coupon_wrapper->type
->value() == 'discount_coupon') {
foreach ($coupon_wrapper->commerce_discount_reference
->value() as $discount) {
if ($discount && $discount->name == $discount_name) {
return TRUE;
}
}
}
}