| 1 |
<?php |
| 2 |
/** |
| 3 |
* Trait WcTaxTrait. |
| 4 |
* |
| 5 |
* @package Packetery |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace Packetery\Module\Framework; |
| 11 |
|
| 12 |
use WC_Tax; |
| 13 |
|
| 14 |
/** |
| 15 |
* Trait WcTaxTrait. |
| 16 |
* |
| 17 |
* @package Packetery |
| 18 |
*/ |
| 19 |
trait WcTaxTrait { |
| 20 |
public function taxGetRates( string $taxClass, ?object $customer = null ): array { |
| 21 |
return WC_Tax::get_rates( $taxClass, $customer ); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* @return array<int, array<string, string|float>>|array{} |
| 26 |
*/ |
| 27 |
public function taxGetShippingTaxRates(): array { |
| 28 |
return (array) WC_Tax::get_shipping_tax_rates(); |
| 29 |
} |
| 30 |
|
| 31 |
public function calcTax( float $price, array $rates, bool $priceIncludesTax ): array { |
| 32 |
return WC_Tax::calc_tax( $price, $rates, $priceIncludesTax ); |
| 33 |
} |
| 34 |
|
| 35 |
public function taxCalcInclusiveTax( float $cost, array $rates ): array { |
| 36 |
return WC_Tax::calc_inclusive_tax( $cost, $rates ); |
| 37 |
} |
| 38 |
} |
| 39 |
|