function commerce_coupon_load_coupon_code_discounts in Commerce Coupon 7.2
Load the discounts associated with a coupon code.
Parameters
string $code: Commerce coupon code.
Return value
array A list of discounts.
1 call to commerce_coupon_load_coupon_code_discounts()
File
- ./
commerce_coupon.module, line 1277 - Provides coupon functionality for Drupal Commerce.
Code
function commerce_coupon_load_coupon_code_discounts($code) {
$discounts = array();
$coupon = commerce_coupon_load_by_code($code);
if ($coupon) {
/** @var \EntityDrupalWrapper $coupon_wrapper */
$coupon_wrapper = entity_metadata_wrapper('commerce_coupon', $coupon);
if ($coupon_wrapper
->getBundle() == 'discount_coupon') {
/** @var CommerceDiscount $discount */
foreach ($coupon_wrapper->commerce_discount_reference
->value() as $discount) {
if ($discount->status) {
$discounts[] = $discount;
}
}
}
}
return $discounts;
}