PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.0 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 All 92 releases
← All changes | src/Addons/GlobalTieredPricing/PricingService.php +12 -9 6.4.0 → 8.1.0 View file →
@@ -3,9 +3,8 @@
3 3 namespace TierPricingTable\Addons\GlobalTieredPricing;
4 4
5 5 use TierPricingTable\PricingRule;
6 6 use TierPricingTable\Addons\TieredPricingCart\CartOptionsSubsection;
7 -use TierPricingTable\PriceManager;
8 7 class PricingService {
9 8 public function __construct() {
10 9 /**
11 10 * Main function to filter the tiered pricing rules
@@ -27,9 +26,9 @@
27 26 // If priority is set to default, use the global settings
28 27 if ( 'default' === $priority ) {
29 28 $priority = ( CartOptionsSubsection::globalRulesOverrideProductLevelRules() ? 'override' : 'prefer-product' );
30 29 }
31 - $pricingRule->logPricingModification( '[global rule]: Matched global pricing rule #' . $globalPricingRule->getId() . ' with priority: ' . $priority );
30 + $pricingRule->logPricingModification( '[global rule]: Matched global pricing rule #' . $globalPricingRule->getId() . ' (priority ' . $globalPricingRule->getPriority() . ') with priority type: ' . $priority );
32 31 $pricingRule = apply_filters(
33 32 'tiered_pricing_table/global_pricing/before_adjusting_pricing_rule',
34 33 $pricingRule,
35 34 $globalPricingRule,
@@ -65,9 +64,8 @@
65 64 }
66 65
67 66 public function addFlexibleGlobalPricing( PricingRule $pricingRule, GlobalPricingRule $globalPricingRule ) : PricingRule {
68 67 $updateRegularPricing = false;
69 - $updateQuantityLimits = false;
70 68 $updateTieredPricing = false;
71 69 /**
72 70 * Regular prices
73 71 */
@@ -80,20 +78,25 @@
80 78 }
81 79 /**
82 80 * Quantity Limits
83 81 */
82 + $updateMinimum = false;
83 + $updateMixAndMatch = false;
84 84 if ( $globalPricingRule->getSettings()->getQuantityLimitsPriority() === 'prefer-role-based-product' ) {
85 - // Update only if there are no quantity limits set in the product or role-based
86 85 if ( $pricingRule->provider !== 'role-based' ) {
87 - $updateQuantityLimits = true;
86 + $updateMinimum = true;
87 + $updateMixAndMatch = true;
88 88 }
89 89 } elseif ( $globalPricingRule->getSettings()->getQuantityLimitsPriority() === 'prefer-product' ) {
90 - // Update only if there are no quantity limits set in the product
91 90 if ( empty( $pricingRule->getMinimum() ) ) {
92 - $updateQuantityLimits = true;
91 + $updateMinimum = true;
93 92 }
93 + if ( get_post_meta( $pricingRule->getProductId(), '_tiered_price_mix_and_match_minimum', true ) === '' ) {
94 + $updateMixAndMatch = true;
95 + }
94 96 } else {
95 - $updateQuantityLimits = true;
97 + $updateMinimum = true;
98 + $updateMixAndMatch = true;
96 99 }
97 100 /**
98 101 * Tiered Pricing
99 102 */
@@ -109,9 +112,9 @@
109 112 $updateTieredPricing = true;
110 113 }
111 114 if ( $updateRegularPricing ) {
112 115 }
113 - if ( $updateQuantityLimits ) {
116 + if ( $updateMinimum || $updateMixAndMatch ) {
114 117 }
115 118 if ( $updateTieredPricing ) {
116 119 $pricingRule->setRules( $globalPricingRule->getTieredPricingRules() );
117 120 $pricingRule->setType( $globalPricingRule->getTieredPricingType() );