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
← All changes | src/Services/ProductPageService.php +13 -8 6.5.0 → 8.0.2 View file →
@@ -2,8 +2,9 @@
2 2
3 3 use Exception;
4 4 use TierPricingTable\Admin\ProductPage\TieredPricingTab;
5 5 use TierPricingTable\Core\ServiceContainerTrait;
6 +use TierPricingTable\Settings\Sections\GeneralSection\GeneralSection;
6 7 use TierPricingTable\PriceManager;
7 8 use TierPricingTable\PricingTable;
8 9 use TierPricingTable\Settings\Sections\GeneralSection\Subsections\ProductPagePriceSubsection;
9 10 use TierPricingTable\TierPricingTablePlugin;
@@ -39,10 +40,9 @@
39 40 // Wrap price
40 41 add_action( 'woocommerce_get_price_html', array( $this, 'wrapPrice' ), 101, 2 );
41 42
42 43 // Render price table
43 - add_action( $this->getContainer()->getSettings()->get( 'position_hook',
44 - 'woocommerce_before_add_to_cart_button' ), array(
44 + add_action( GeneralSection::getPositionHook(), array(
45 45 $this,
46 46 'renderPricingTableOnProductPage',
47 47 ), - 999 );
48 48
@@ -138,12 +138,13 @@
138 138 }
139 139
140 140 $isVariable = in_array( $product->get_type(), TierPricingTablePlugin::getSupportedVariableProductTypes() );
141 141
142 - $pricingRules = PriceManager::getPricingRule( $product->get_id() );
142 + $pricingRules = \TierPricingTable\PriceManager::getPricingRule( $product->get_id() );
143 143
144 - // Do not wrap if there is no pricing rules
145 - if ( ! $isVariable && empty( $pricingRules->getRules() ) ) {
144 + // Set to no-rules if there are no pricing rules and the main dynamic price setting is disabled
145 + $updatePrice = $this->getContainer()->getSettings()->get( 'update_price_on_product_page', 'yes' ) === 'yes';
146 + if ( ! $isVariable && empty( $pricingRules->getRules() ) && ! $updatePrice ) {
146 147 $priceType = 'no-rules';
147 148 }
148 149
149 150 $supportedTypes = array_merge( TierPricingTablePlugin::getSupportedSimpleProductTypes(), array( 'variation' ) );
@@ -150,11 +151,15 @@
150 151
151 152 $wrapVariableProductPrice = apply_filters( 'tiered_pricing_table/frontend/wrap_variable_price', true,
152 153 $product );
153 154
155 + $hasRules = PricingTable::getInstance()->productHasPricingRules( $product );
156 + $showTotalPrice = $hasRules
157 + ? $this->getContainer()->getSettings()->get( 'show_total_price', 'no' ) === 'yes'
158 + : $this->getContainer()->getSettings()->get( 'show_total_price_non_tiered', 'no' ) === 'yes';
159 +
154 160 // Is "show total price" is enabled, we can wrap the variable product price, or it's forced by the hook
155 - if ( $wrapVariableProductPrice || $this->getContainer()->getSettings()->get( 'show_total_price',
156 - 'no' ) === 'yes' ) {
161 + if ( $wrapVariableProductPrice || $showTotalPrice ) {
157 162 $supportedTypes = array_merge( $supportedTypes,
158 163 TierPricingTablePlugin::getSupportedVariableProductTypes() );
159 164 }
160 165
@@ -236,9 +241,9 @@
236 241 */
237 242 public function renderTooltip( ?string $price, WC_Product $_product ): ?string {
238 243
239 244 // Do not render if not display
240 - if ( 'yes' !== $this->getContainer()->getSettings()->get( 'display', 'yes' ) ) {
245 + if ( ! GeneralSection::isAutomaticDisplayEnabled() ) {
241 246 return $price;
242 247 }
243 248
244 249 $displayType = TieredPricingTab::getProductTemplate( $_product->get_parent_id() ? $_product->get_parent_id() : $_product->get_id() );