| 1 |
<?php namespace TierPricingTable\Addons\GlobalTieredPricing; |
| 2 |
|
| 3 |
use TierPricingTable\Addons\AbstractAddon; |
| 4 |
use TierPricingTable\Addons\GlobalTieredPricing\CPT\GlobalTieredPricingCPT; |
| 5 |
|
| 6 |
class GlobalTieredPricingAddon extends AbstractAddon { |
| 7 |
|
| 8 |
public function getName(): string { |
| 9 |
return __( 'Global pricing rules', 'tier-pricing-table' ); |
| 10 |
} |
| 11 |
|
| 12 |
public function run() { |
| 13 |
|
| 14 |
// Enable pricing service |
| 15 |
add_filter( 'tiered_pricing_table/services/pricing_service_enabled', '__return_true' ); |
| 16 |
|
| 17 |
new LookupService(); |
| 18 |
new GlobalTieredPricingCPT(); |
| 19 |
new GlobalTieredPricingCartManager(); |
| 20 |
new PricingService(); |
| 21 |
|
| 22 |
GlobalPricingRulesRepository::getInstance(); |
| 23 |
|
| 24 |
add_action( 'tiered_pricing_table/admin/pricing_tab_end', array( |
| 25 |
$this, |
| 26 |
'showMessageOnProductsTieredPricingTab', |
| 27 |
), 999 ); |
| 28 |
} |
| 29 |
|
| 30 |
public function showMessageOnProductsTieredPricingTab() { |
| 31 |
$globalRules = GlobalTieredPricingCPT::getGlobalRules( false ); |
| 32 |
|
| 33 |
if ( empty( $globalRules ) ) { |
| 34 |
$this->getContainer()->getFileManager()->includeTemplate( 'addons/global-rules/tiered-pricing-tab.php' ); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
public function getDescription(): string { |
| 39 |
return __( 'Create pricing rules for user roles or specific users, and apply them to selected products or product categories.', |
| 40 |
'tier-pricing-table' ); |
| 41 |
} |
| 42 |
|
| 43 |
public function getSlug(): string { |
| 44 |
return 'global-tier-pricing'; |
| 45 |
} |
| 46 |
} |
| 47 |
|