/**
  * Calculate total 'product fixed' and 'product percentage' discounts
  *
  * @param  fflcommerce_product $_product the product we are working with
  * @param  array $values the cart values for this product
  * @return float|int|mixed|void $current_product_discount
  */
 private static function calculate_product_discounts_total($_product, $values)
 {
     $current_product_discount = 0;
     if (!empty(self::$applied_coupons)) {
         foreach (self::$applied_coupons as $code) {
             $coupon_discount = 0;
             $coupon = JS_Coupons::get_coupon($code);
             if (!JS_Coupons::is_valid_coupon_for_product($code, $values)) {
                 continue;
             }
             $price = self::get_options()->get('fflcommerce_tax_after_coupon') == 'yes' ? $_product->get_price_excluding_tax() : $_product->get_price_with_tax();
             switch ($coupon['type']) {
                 case 'fixed_product':
                     $coupon_discount = apply_filters('fflcommerce_coupon_product_fixed_amount', $coupon['amount'], $coupon) * $values['quantity'];
                     if ($coupon_discount > $price * $values['quantity']) {
                         $coupon_discount = $price * $values['quantity'];
                     }
                     break;
                 case 'percent_product':
                     $coupon_discount = $price * $values['quantity'] / 100 * $coupon['amount'];
                     break;
             }
             $current_product_discount += $coupon_discount;
         }
     }
     return $current_product_discount;
 }