| @@ 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 ); |
|
| @@ 1452-1471 (lines=20) @@ | ||
| 1449 | } |
|
| 1450 | } |
|
| 1451 | ||
| 1452 | if ( !empty( $tax_rates ) ) { |
|
| 1453 | foreach ( $tax_rates as $key => $tax_rate ) { |
|
| 1454 | if ( $country != $tax_rate['country'] ) |
|
| 1455 | continue; |
|
| 1456 | ||
| 1457 | if ( !empty( $tax_rate['global'] ) ) { |
|
| 1458 | if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
| 1459 | $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 1460 | } |
|
| 1461 | } else { |
|
| 1462 | if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1463 | continue; |
|
| 1464 | ||
| 1465 | $state_rate = $tax_rate['rate']; |
|
| 1466 | if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 1467 | $rate = number_format( $state_rate, 4 ); |
|
| 1468 | } |
|
| 1469 | } |
|
| 1470 | } |
|
| 1471 | } |
|
| 1472 | ||
| 1473 | return $rate; |
|
| 1474 | } |
|