You are here

function uc_coupon_uc_order in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 7.2 uc_coupon.module \uc_coupon_uc_order()

Implements hook_uc_order().

File

./uc_coupon.module, line 1391
Provides discount codes and gift certificates for Ubercart.

Code

function uc_coupon_uc_order($op, &$order) {
  if ($op == 'presave') {

    // Apply any session coupons to the current cart order.
    if (_uc_coupon_is_checkout_order($order)) {
      $coupons = uc_coupon_session_validate($order);
      uc_coupon_apply_to_order($order, $coupons);
    }

    // Make sure any fake cart items don't get saved with the order if the checkout page is skipped
    // (e.g. Paypal Express Checkout, Google Checkout)
    foreach ($order->products as $key => $product) {
      if (isset($product->module) && $product->module == 'uc_coupon') {
        unset($order->products[$key]);
      }
    }
  }
}