One of our clients requested that on the invoice and the order view page they list the Coupon Code and also the discount amount for that order.

I think they might not be the only ones that will have this request.

Comments

andreiashu’s picture

Sorry I can't really provide a patch right now. I'll just paste in the code used to implement the coupon code for the order. The discount value for the coupon code I solved by putting it directly in the CA title (e. Coupon code (40%) ).

/**
 * Implementation of hook_token_values().
 */
function uc_discount_token_values($type, $object = NULL) {
  $values = array();
  switch ($type) {
    case 'order':
      $order = $object;
      $values['order-discount-coupon-code'] = isset($order->data['coupon_code']) ? check_plain($order->data['coupon_code']) : '';

      break;
  }

  return $values;
}

/**
 * Implementation of hook_token_list().
 */
function uc_discount_token_list($type = 'all') {
  $tokens = array();
  if ($type == 'order' || $type == 'ubercart' || $type == 'all') {
    $tokens['order']['order-discount-coupon-code'] = t('The entered coupon code for this order.');
  }

  return $tokens;
}