You are here

function commerce_coupon_reset_usage in Commerce Coupon 7.2

Remove usage records related to a set of orders or a set of coupons or both.

Parameters

int $order_id: An order id.

int $coupon_id: A coupon id.

2 calls to commerce_coupon_reset_usage()
commerce_coupon_usage_commerce_order_delete in modules/usage/commerce_coupon_usage.module
Implements hook_commerce_order_delete().
commerce_coupon_usage_commerce_order_update in modules/usage/commerce_coupon_usage.module
Implements hook_commerce_order_update().

File

modules/usage/commerce_coupon_usage.module, line 504

Code

function commerce_coupon_reset_usage($order_ids = FALSE, $coupon_ids = FALSE) {
  $query = db_delete('commerce_coupon_usage_transaction');
  if ($order_ids) {
    $query
      ->condition('order_id', $order_ids);
  }
  if ($coupon_ids) {
    $query
      ->condition('coupon_id', $coupon_ids);
  }
  if ($order_ids || $coupon_ids) {
    $query
      ->execute();
  }
}