function commerce_coupon_get_coupons_in_order in Commerce Coupon 7
Returns the number of uses for this coupon.
Parameters
$order_id: Id from the Commerce order.
Return value
integer Returns number of uses of the coupon in all orders.
1 call to commerce_coupon_get_coupons_in_order()
- commerce_coupon_action_get_coupons_for_order in ./
commerce_coupon.module - Returns a list of coupons that have been attached to the order.
File
- ./
commerce_coupon.module, line 1098 - Coupon System for Drupal Commerce.
Code
function commerce_coupon_get_coupons_in_order($order_id) {
$order_wrapper = entity_metadata_wrapper('commerce_order', $order_id);
$coupons = array();
foreach ($order_wrapper->commerce_coupon_order_reference as $coupon_wrapper) {
if ($coupon_wrapper
->value()->is_active == 1) {
$coupons[] = $coupon_wrapper
->value();
}
}
return $coupons;
}