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 / HorizontalTableAdapter.php

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

44 lines 1.6 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 HorizontalTableAdapter extends AbstractLayoutAdapter {
7
8 public function registerHooks() {
9 add_action( 'tiered_pricing_table/horizontal-table/after_columns', array( $this, 'render' ), 10, 2 );
10 }
11
12 public function render( PricingRule $pricingRule, $settings = array() ) {
13 $form = $this->getValidFormForIntegratedPosition( $pricingRule );
14 if ( ! $form ) {
15 return;
16 }
17
18 $productId = $pricingRule->getProductId();
19
20 $hasQty = ! empty( $settings['quantity_column_title'] ) || ! isset( $settings['quantity_column_title'] );
21 $hasDiscount = ! empty( $settings['discount_column_title'] ); // the layout draws the discount row from its header only
22 $hasPrice = ! empty( $settings['price_column_title'] ) || ! isset( $settings['price_column_title'] );
23
24 // one empty cell per custom column, so the column keeps the grid's row count
25 ob_start();
26 do_action( 'tiered_pricing_table/tiered_pricing/header_columns', $pricingRule );
27 $customColumns = substr_count( (string) ob_get_clean(), '<th' );
28
29 ServiceContainer::getInstance()->getFileManager()->includeTemplate(
30 'frontend/integrated/horizontal-table.php',
31 array(
32 'form' => $form,
33 'productId' => $productId,
34 'hasQty' => $hasQty,
35 'hasDiscount' => $hasDiscount,
36 'hasPrice' => $hasPrice,
37 'customColumns' => $customColumns,
38 'buttonHtml' => $this->getQuoteButtonHtml( $form, $productId, 'button wp-element-button', 'padding: 5px 10px;margin:0', 'tpt-raq-table' )
39 ),
40 plugin_dir_path( dirname( __DIR__ ) ) . 'views/'
41 );
42 }
43 }
44