2) { $calc_discount = ($decimal_val == 0) ? $discount_amount : (($decimal_val > 0.5) ? ceil($discount_amount) : floor($discount_amount)); } else { $calc_discount = $discount_amount; } return (float) wc_remove_number_precision($calc_discount); } /** * Whether a per-unit discount should be multiplied by line quantity in coupon totals. * * @param string $discount_type Rule type slug. * @param int $rule_id Rule post ID. */ public static function coupon_amount_is_per_unit($discount_type, $rule_id = 0) { if (in_array($discount_type, self::line_price_discount_types(), true)) { return true; } if ('cart_quantity' === $discount_type && 'type_product' === self::get_quantity_discount_type($rule_id)) { return true; } return false; } }