| 1 |
<?php |
| 2 |
|
| 3 |
namespace TierPricingTable\Addons\RequestAQuote; |
| 4 |
|
| 5 |
use TierPricingTable\Addons\AbstractAddon; |
| 6 |
class RequestAQuoteAddon extends AbstractAddon { |
| 7 |
public function getName() : string { |
| 8 |
return __( 'Request a Quote', 'tier-pricing-table' ); |
| 9 |
} |
| 10 |
|
| 11 |
public function getDescription() : string { |
| 12 |
return __( 'Allow customers to request a custom quote.', 'tier-pricing-table' ); |
| 13 |
} |
| 14 |
|
| 15 |
public function getIcon() : string { |
| 16 |
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>'; |
| 17 |
} |
| 18 |
|
| 19 |
public function getSlug() : string { |
| 20 |
return 'request-a-quote'; |
| 21 |
} |
| 22 |
|
| 23 |
public function run() { |
| 24 |
// Always init settings and forms REST API so users can create forms |
| 25 |
new Settings\Settings(); |
| 26 |
add_action( 'rest_api_init', function () { |
| 27 |
( new API\FormsEndpoint() )->register_routes(); |
| 28 |
( new API\SettingsEndpoint() )->register_routes(); |
| 29 |
} ); |
| 30 |
// Conditionally init the rest if forms exist |
| 31 |
$forms = Models\RequestQuoteForm::getAll(); |
| 32 |
if ( empty( $forms ) ) { |
| 33 |
return; |
| 34 |
} |
| 35 |
new Frontend\QuoteFormDisplay(); |
| 36 |
new Frontend\API\SubmitQuoteEndpoint(); |
| 37 |
new Integration\PricingRulesIntegration(); |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
|