← All changes
|
src/Addons/RequestAQuote/Frontend/Adapters/TableAdapter.php
+10
-1
7.1.5
→
8.0.2
View file →
| @@ -20,11 +20,18 @@ | ||
| 20 | 20 | |
| 21 | 21 | $isDivTable = strpos( $templateName, 'style-' ) !== false; |
| 22 | 22 | |
| 23 | 23 | $hasQty = ! empty( $settings['quantity_column_title'] ) || ! isset( $settings['quantity_column_title'] ); |
| 24 | - $hasDiscount = ! empty( $settings['discount_column_title'] ) || ! empty( $settings['show_discount_column'] ); | |
| 24 | + $hasDiscount = ! empty( $settings['discount_column_title'] ); // the table draws the discount column from its header only | |
| 25 | 25 | $hasPrice = ! empty( $settings['price_column_title'] ) || ! isset( $settings['price_column_title'] ); |
| 26 | 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 | + | |
| 27 | 34 | ServiceContainer::getInstance()->getFileManager()->includeTemplate( 'frontend/integrated/table.php', array( |
| 28 | 35 | 'form' => $form, |
| 29 | 36 | 'productId' => $pricingRule->getProductId(), |
| 30 | 37 | 'isDivTable' => $isDivTable, |
| @@ -30,8 +37,10 @@ | ||
| 30 | 37 | 'isDivTable' => $isDivTable, |
| 31 | 38 | 'hasQty' => $hasQty, |
| 32 | 39 | 'hasPrice' => $hasPrice, |
| 33 | 40 | 'hasDiscount' => $hasDiscount, |
| 41 | + 'columns' => $columns, | |
| 42 | + 'span' => $span, | |
| 34 | 43 | 'buttonHtml' => $this->getQuoteButtonHtml( $form, $pricingRule->getProductId(), |
| 35 | 44 | $isDivTable ? 'button wp-element-button' : 'button wp-element-button alt', |
| 36 | 45 | 'padding: 5px 10px;margin:0; float:right', 'tpt-raq-table' ), |
| 37 | 46 | ), plugin_dir_path( dirname( __DIR__ ) ) . 'views/' ); |