| 1 |
<?php namespace TierPricingTable\Addons\RequestAQuote\Frontend\Adapters; |
| 2 |
|
| 3 |
use TierPricingTable\Core\ServiceContainer; |
| 4 |
use TierPricingTable\PricingRule; |
| 5 |
|
| 6 |
class TableAdapter extends AbstractLayoutAdapter { |
| 7 |
|
| 8 |
public function registerHooks() { |
| 9 |
add_action( 'tiered_pricing_table/tiered_pricing/rows', array( $this, 'render' ), 10, 3 ); |
| 10 |
add_action( 'tiered_pricing_table/tiered_pricing/after', array( $this, 'renderFormPrompt' ), 10, 2 ); |
| 11 |
} |
| 12 |
|
| 13 |
public function render( PricingRule $pricingRule, $settings = array(), $templateName = 'tiered-pricing-table' ) { |
| 14 |
|
| 15 |
$form = $this->getValidFormForIntegratedPosition( $pricingRule ); |
| 16 |
|
| 17 |
if ( ! $form ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
$isDivTable = strpos( $templateName, 'style-' ) !== false; |
| 22 |
|
| 23 |
$hasQty = ! empty( $settings['quantity_column_title'] ) || ! isset( $settings['quantity_column_title'] ); |
| 24 |
$hasDiscount = ! empty( $settings['discount_column_title'] ) || ! empty( $settings['show_discount_column'] ); |
| 25 |
$hasPrice = ! empty( $settings['price_column_title'] ) || ! isset( $settings['price_column_title'] ); |
| 26 |
|
| 27 |
ServiceContainer::getInstance()->getFileManager()->includeTemplate( 'frontend/integrated/table.php', array( |
| 28 |
'form' => $form, |
| 29 |
'productId' => $pricingRule->getProductId(), |
| 30 |
'isDivTable' => $isDivTable, |
| 31 |
'hasQty' => $hasQty, |
| 32 |
'hasPrice' => $hasPrice, |
| 33 |
'hasDiscount' => $hasDiscount, |
| 34 |
'buttonHtml' => $this->getQuoteButtonHtml( $form, $pricingRule->getProductId(), |
| 35 |
$isDivTable ? 'button wp-element-button' : 'button wp-element-button alt', |
| 36 |
'padding: 5px 10px;margin:0; float:right', 'tpt-raq-table' ), |
| 37 |
), plugin_dir_path( dirname( __DIR__ ) ) . 'views/' ); |
| 38 |
} |
| 39 |
} |
| 40 |
|