/**
  * Apply sign up fee or recurring fee discount after tax is calculated
  *
  * Unable to handle percentage discounts without having correct price to calculate discount
  * Unable to check if the after-tax price is less than the coupon amount without having after tax price available
  * Hook added in WC 1.7 fixes these issues
  *
  * @since 1.2
  */
 public static function apply_subscription_discount_after_tax($coupon)
 {
     global $woocommerce;
     if (sizeof($woocommerce->cart->cart_contents) > 0) {
         foreach ($woocommerce->cart->cart_contents as $cart_item_key => $values) {
             if (!$coupon->apply_before_tax() && $coupon->is_valid() && self::is_subscription_discountable($values, $coupon)) {
                 if ('sign_up_fee' == WC_Subscriptions_Cart::get_recalculation_type() && 'sign_up_fee' == $coupon->type || 'base_recurring_fee' == WC_Subscriptions_Cart::get_recalculation_type() && 'recurring_fee' == $coupon->type || 0 == WC_Subscriptions_Cart::get_cart_subscription_sign_up_fee() && 'recurring_fee' == $coupon->type) {
                     $woocommerce->cart->discount_total = $woocommerce->cart->discount_total + $coupon->amount * $values['quantity'];
                 }
             }
         }
     }
 }