| @@ -49,10 +49,12 @@ | ||
| 49 | 49 | $this->fileManager = $fileManager; |
| 50 | 50 | $this->settings = $settings; |
| 51 | 51 | $this->licence = $licence; |
| 52 | 52 | $this->initManagers(); |
| 53 | - // Render price table | |
| 54 | - add_action( $this->settings->get( 'position_hook', 'woocommerce_before_add_to_cart_button' ), [ $this, 'displayPricingTable' ], -999 ); | |
| 53 | + if ( $this->settings->get( 'display', 'yes' ) == 'yes' ) { | |
| 54 | + // Render price table | |
| 55 | + add_action( $this->settings->get( 'position_hook', 'woocommerce_before_add_to_cart_button' ), [ $this, 'displayPricingTable' ], -999 ); | |
| 56 | + } | |
| 55 | 57 | // Wrap price |
| 56 | 58 | add_action( |
| 57 | 59 | 'woocommerce_get_price_html', |
| 58 | 60 | [ $this, 'wrapPrice' ], |
| @@ -83,27 +85,8 @@ | ||
| 83 | 85 | ); |
| 84 | 86 | } |
| 85 | 87 | } |
| 86 | 88 | |
| 87 | - public function renderSummary() | |
| 88 | - { | |
| 89 | - global $post ; | |
| 90 | - if ( !$post ) { | |
| 91 | - return; | |
| 92 | - } | |
| 93 | - $product = wc_get_product( $post->ID ); | |
| 94 | - if ( !$product ) { | |
| 95 | - return; | |
| 96 | - } | |
| 97 | - $type = $this->settings->get( 'summary_type', 'table' ); | |
| 98 | - $this->fileManager->includeTemplate( 'frontend/summary-' . $type . '.php', array( | |
| 99 | - 'needHide' => $product->is_type( 'variable' ), | |
| 100 | - 'totalLabel' => $this->settings->get( 'summary_total_label', 'Total:' ), | |
| 101 | - 'eachLabel' => $this->settings->get( 'summary_each_label', 'Each:' ), | |
| 102 | - 'title' => $this->settings->get( 'summary_title', '' ), | |
| 103 | - ) ); | |
| 104 | - } | |
| 105 | - | |
| 106 | 89 | /** |
| 107 | 90 | * |
| 108 | 91 | */ |
| 109 | 92 | protected function initManagers() |
| @@ -250,21 +233,18 @@ | ||
| 250 | 233 | return; |
| 251 | 234 | } |
| 252 | 235 | $rules = PriceManager::getPriceRules( $product_id ); |
| 253 | 236 | $real_price = ( !is_null( $variation_id ) ? wc_get_product( $variation_id )->get_price() : $product->get_price() ); |
| 254 | - $product_name = ( !is_null( $variation_id ) ? wc_get_product( $variation_id )->get_name() : $product->get_name() ); | |
| 255 | 237 | |
| 256 | 238 | if ( !empty($rules) ) { |
| 257 | - $template = ( 'percentage' === PriceManager::getPricingType( $product_id ) ? 'price-table-percentage.php' : 'price-table-fixed.php' ); | |
| 258 | - $this->fileManager->includeTemplate( 'frontend/' . $template, array( | |
| 259 | - 'price_rules' => $rules, | |
| 260 | - 'real_price' => $real_price, | |
| 261 | - 'product_name' => $product_name, | |
| 262 | - 'product_id' => $product_id, | |
| 263 | - 'minimum' => PriceManager::getProductQtyMin( $product_id, 'view' ), | |
| 264 | - 'settings' => $this->settings->getAll(), | |
| 265 | - ) ); | |
| 239 | + $template = ( PriceManager::getPricingType( $product_id ) === 'percentage' ? 'price-table-percentage.php' : 'price-table-fixed.php' ); | |
| 240 | + $this->fileManager->includeTemplate( 'frontend/' . $template, [ | |
| 241 | + 'price_rules' => $rules, | |
| 242 | + 'real_price' => $real_price, | |
| 243 | + 'product_id' => $product_id, | |
| 244 | + 'settings' => $this->settings->getAll(), | |
| 245 | + ] ); | |
| 266 | 246 | } |
| 267 | 247 | |
| 268 | 248 | } |
| 269 | 249 | |
| 270 | 250 | } |