Code Duplication    Length = 18-18 lines in 2 locations

includes/wpinv-discount-functions.php 2 locations

@@ 523-540 (lines=18) @@
520
    return apply_filters( 'wpinv_is_discount_maxed_out', $return, $code_id );
521
}
522
523
function wpinv_discount_is_min_met( $code_id = null ) {
524
    $discount = wpinv_get_discount( $code_id );
525
    $return   = false;
526
527
    if ( $discount ) {
528
        $min         = (float)wpinv_get_discount_min_total( $code_id );
529
        $cart_amount = (float)wpinv_get_cart_discountable_subtotal( $code_id );
530
531
        if ( !$min > 0 || $cart_amount >= $min ) {
532
            // Minimum has been met
533
            $return = true;
534
        } else {
535
            wpinv_set_error( 'wpinv-discount-error', sprintf( __( 'Minimum invoice amount should be %s', 'invoicing' ), wpinv_price( wpinv_format_amount( $min ) ) ) );
536
        }
537
    }
538
539
    return apply_filters( 'wpinv_is_discount_min_met', $return, $code_id );
540
}
541
542
function wpinv_discount_is_max_met( $code_id = null ) {
543
    $discount = wpinv_get_discount( $code_id );
@@ 542-559 (lines=18) @@
539
    return apply_filters( 'wpinv_is_discount_min_met', $return, $code_id );
540
}
541
542
function wpinv_discount_is_max_met( $code_id = null ) {
543
    $discount = wpinv_get_discount( $code_id );
544
    $return   = false;
545
546
    if ( $discount ) {
547
        $max         = (float)wpinv_get_discount_max_total( $code_id );
548
        $cart_amount = (float)wpinv_get_cart_discountable_subtotal( $code_id );
549
550
        if ( !$max > 0 || $cart_amount <= $max ) {
551
            // Minimum has been met
552
            $return = true;
553
        } else {
554
            wpinv_set_error( 'wpinv-discount-error', sprintf( __( 'Maximum invoice amount should be %s', 'invoicing' ), wpinv_price( wpinv_format_amount( $max ) ) ) );
555
        }
556
    }
557
558
    return apply_filters( 'wpinv_is_discount_max_met', $return, $code_id );
559
}
560
561
function wpinv_discount_is_single_use( $code_id = 0 ) {
562
    $single_use = get_post_meta( $code_id, '_wpi_discount_is_single_use', true );