| 1 |
<?php namespace TierPricingTable\Addons\RequestAQuote\Frontend\Adapters; |
| 2 |
|
| 3 |
use TierPricingTable\Core\ServiceContainer; |
| 4 |
use TierPricingTable\PricingRule; |
| 5 |
|
| 6 |
class BlocksAdapter extends AbstractLayoutAdapter { |
| 7 |
|
| 8 |
public function registerHooks() { |
| 9 |
// Default |
| 10 |
add_action( 'tiered_pricing_table/blocks/after_blocks', array( $this, 'renderFormPrompt' ), 10, 1 ); |
| 11 |
// Integrated |
| 12 |
add_action( 'tiered_pricing_table/blocks/blocks', array( $this, 'render' ), 10, 2 ); |
| 13 |
} |
| 14 |
|
| 15 |
public function render( PricingRule $pricingRule, $settings = array() ) { |
| 16 |
$form = $this->getValidFormForIntegratedPosition( $pricingRule ); |
| 17 |
if ( ! $form ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
$blocksStyle = $settings['blocks_style'] ?? 'default'; |
| 22 |
$promptText = $form->getPromptText(); |
| 23 |
$formId = $form->getId(); |
| 24 |
$productId = $pricingRule->getProductId(); |
| 25 |
|
| 26 |
ServiceContainer::getInstance()->getFileManager()->includeTemplate( |
| 27 |
'frontend/integrated/blocks.php', |
| 28 |
array( |
| 29 |
'form' => $form, |
| 30 |
'productId' => $productId, |
| 31 |
'blocksStyle' => $blocksStyle, |
| 32 |
'promptText' => $promptText, |
| 33 |
'buttonHtml' => $this->getQuoteButtonHtml( $form, $productId, '', '', 'tpt-raq-link', true ) |
| 34 |
), |
| 35 |
plugin_dir_path( dirname( __DIR__ ) ) . 'views/' |
| 36 |
); |
| 37 |
} |
| 38 |
} |
| 39 |
|