function uc_coupon_get_order_coupons in Ubercart Discount Coupons 7.3
Gets the fully validated coupon objects that have been applied to this order.
Parameters
$order: The order in question.
$recalculate: If TRUE, the value of each coupon will be recalculated using the current state of the order and current coupon settings. If FALSE (default), the original coupon values will be preserved.
3 calls to uc_coupon_get_order_coupons()
- uc_coupon_form in ./
uc_coupon.module - Form builder for the uc_coupon form.
- uc_coupon_order_submit in ./
uc_coupon.module - uc_coupon_workflow_uc_checkout_complete in uc_coupon_workflow/
uc_coupon_workflow.module - Implements hook uc_checkout_complete().
File
- ./
uc_coupon.module, line 2287 - Provides discount codes and gift certificates for Ubercart.
Code
function uc_coupon_get_order_coupons($order, $recalculate = FALSE) {
$coupons = array();
if (!empty($order->data['coupons'])) {
if ($recalculate) {
$dummy_order = clone $order;
$dummy_order->data['coupons'] = array();
}
foreach ($order->data['coupons'] as $code => $discounts) {
$coupon = uc_coupon_find($code);
if (!empty($coupon->cid)) {
if ($recalculate) {
$discounts = uc_coupon_calculate_discounts($coupon, $dummy_order);
$dummy_order->data['coupons'][$code] = $coupon->discounts;
}
$coupons[] = uc_coupon_prepare($coupon, $code, $discounts);
}
}
}
return $coupons;
}