PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
tier-pricing-table / src / Addons / RequestAQuote / Frontend / Adapters / TableAdapter.php

TableAdapter.php in Tiered Pricing Table for WooCommerce 8.0.2, at src/Addons/RequestAQuote/Frontend/Adapters/TableAdapter.php

49 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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'] ); // the table draws the discount column from its header only
25 $hasPrice = ! empty( $settings['price_column_title'] ) || ! isset( $settings['price_column_title'] );
26
27 // the row spans the whole table: the base columns plus whatever the header hook adds (custom columns)
28 ob_start();
29 do_action( 'tiered_pricing_table/tiered_pricing/header_columns', $pricingRule );
30 $extraColumns = (int) preg_match_all( '/<th\b/i', (string) ob_get_clean() );
31 $columns = (int) $hasQty + (int) $hasDiscount + (int) $hasPrice + $extraColumns;
32 $span = max( 1, $columns - (int) $hasQty );
33
34 ServiceContainer::getInstance()->getFileManager()->includeTemplate( 'frontend/integrated/table.php', array(
35 'form' => $form,
36 'productId' => $pricingRule->getProductId(),
37 'isDivTable' => $isDivTable,
38 'hasQty' => $hasQty,
39 'hasPrice' => $hasPrice,
40 'hasDiscount' => $hasDiscount,
41 'columns' => $columns,
42 'span' => $span,
43 'buttonHtml' => $this->getQuoteButtonHtml( $form, $pricingRule->getProductId(),
44 $isDivTable ? 'button wp-element-button' : 'button wp-element-button alt',
45 'padding: 5px 10px;margin:0; float:right', 'tpt-raq-table' ),
46 ), plugin_dir_path( dirname( __DIR__ ) ) . 'views/' );
47 }
48 }
49