Code Duplication    Length = 20-22 lines in 2 locations

includes/wpinv-tax-functions.php 1 location

@@ 70-91 (lines=22) @@
67
    if( !empty( $country ) ) {
68
        $tax_rates   = wpinv_get_tax_rates();
69
70
        if( !empty( $tax_rates ) ) {
71
            // Locate the tax rate for this country / state, if it exists
72
            foreach( $tax_rates as $key => $tax_rate ) {
73
                if( $country != $tax_rate['country'] )
74
                    continue;
75
76
                if( !empty( $tax_rate['global'] ) ) {
77
                    if( !empty( $tax_rate['rate'] ) ) {
78
                        $rate = number_format( $tax_rate['rate'], 4 );
79
                    }
80
                } else {
81
82
                    if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
83
                        continue;
84
85
                    $state_rate = $tax_rate['rate'];
86
                    if( 0 !== $state_rate || !empty( $state_rate ) ) {
87
                        $rate = number_format( $state_rate, 4 );
88
                    }
89
                }
90
            }
91
        }
92
    }
93
    
94
    $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id );

includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 location

@@ 1457-1476 (lines=20) @@
1454
            }
1455
        }
1456
1457
        if ( !empty( $tax_rates ) ) {
1458
            foreach ( $tax_rates as $key => $tax_rate ) {
1459
                if ( $country != $tax_rate['country'] )
1460
                    continue;
1461
1462
                if ( !empty( $tax_rate['global'] ) ) {
1463
                    if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) {
1464
                        $rate = number_format( $tax_rate['rate'], 4 );
1465
                    }
1466
                } else {
1467
                    if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
1468
                        continue;
1469
1470
                    $state_rate = $tax_rate['rate'];
1471
                    if ( 0 !== $state_rate || !empty( $state_rate ) ) {
1472
                        $rate = number_format( $state_rate, 4 );
1473
                    }
1474
                }
1475
            }
1476
        }
1477
        
1478
        return $rate;
1479
    }