| 1 |
<?php namespace TierPricingTable\Services\API; |
| 2 |
|
| 3 |
use TierPricingTable\Services\API\ProductFields\FixedTieredPricing; |
| 4 |
use TierPricingTable\Services\API\ProductFields\MinimumOrderQuantity; |
| 5 |
use TierPricingTable\Services\API\ProductFields\PercentageTieredPricing; |
| 6 |
use TierPricingTable\Services\API\ProductFields\ProductField; |
| 7 |
use TierPricingTable\Services\API\ProductFields\RoleBasedPricingData; |
| 8 |
use TierPricingTable\Services\API\ProductFields\TieredPricingProductSettings; |
| 9 |
use TierPricingTable\Services\API\ProductFields\TieredPricingType; |
| 10 |
use TierPricingTable\Core\ServiceContainerTrait; |
| 11 |
|
| 12 |
class WooCommerceRestAPI { |
| 13 |
|
| 14 |
use ServiceContainerTrait; |
| 15 |
|
| 16 |
public function __construct() { |
| 17 |
add_action( 'rest_api_init', array( $this, 'registerRoutes' ) ); |
| 18 |
} |
| 19 |
|
| 20 |
public function registerRoutes() { |
| 21 |
|
| 22 |
$productFields = apply_filters( 'tiered_pricing_table/api/product_fields', array( |
| 23 |
TieredPricingType::class, |
| 24 |
FixedTieredPricing::class, |
| 25 |
TieredPricingProductSettings::class, |
| 26 |
MinimumOrderQuantity::class, |
| 27 |
RoleBasedPricingData::class, |
| 28 |
PercentageTieredPricing::class, |
| 29 |
) ); |
| 30 |
|
| 31 |
foreach ( $productFields as $productField ) { |
| 32 |
/** |
| 33 |
* Variable type hinting |
| 34 |
* |
| 35 |
* @var ProductField $productField |
| 36 |
*/ |
| 37 |
$productField = new $productField(); |
| 38 |
|
| 39 |
$productField->register(); |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|