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/PriceManager.php +23 -4 6.5.0 → 8.0.2 View file →
@@ -176,8 +176,23 @@
176 176 public static function getProductQtyMin( $productId, ?string $context = 'view' ) : ?int {
177 177 return null;
178 178 }
179 179
180 + public static function isProductMixAndMatch( $productId ) {
181 + $mixAndMatch = get_post_meta( $productId, '_tiered_price_mix_and_match_minimum', true );
182 + if ( '' !== $mixAndMatch ) {
183 + return 'yes' === $mixAndMatch;
184 + }
185 + $product = wc_get_product( $productId );
186 + if ( $product && $product->is_type( 'variation' ) ) {
187 + $parentMixAndMatch = get_post_meta( $product->get_parent_id(), '_tiered_price_mix_and_match_minimum', true );
188 + if ( '' !== $parentMixAndMatch ) {
189 + return 'yes' === $parentMixAndMatch;
190 + }
191 + }
192 + return CalculationLogic::isMixAndMatchMinimumEnabled();
193 + }
194 +
180 195 /**
181 196 * Update product minimum quantity
182 197 *
183 198 * @param int $productId
@@ -247,19 +262,23 @@
247 262 * Set minimum quantity for the product
248 263 *
249 264 ****************************************/
250 265 $minimum = self::getProductQtyMin( $productId );
266 + $isMixAndMatch = self::isProductMixAndMatch( $productId );
251 267 // If product does not have minimum quantity, check parent product
252 268 if ( !$minimum ) {
253 - $product = ( $product ? $product : wc_get_product( $productId ) );
254 269 if ( $product && TierPricingTablePlugin::isVariationProductSupported( $product ) ) {
255 - $minimum = self::getProductQtyMin( $product->get_parent_id() );
256 - if ( $minimum ) {
257 - $pricingRule->logPricingModification( 'Using parent product minimum quantity' );
270 + $parentIsMixAndMatch = $isMixAndMatch;
271 + if ( !$parentIsMixAndMatch ) {
272 + $minimum = self::getProductQtyMin( $product->get_parent_id() );
273 + if ( $minimum ) {
274 + $pricingRule->logPricingModification( 'Using parent product minimum quantity' );
275 + }
258 276 }
259 277 }
260 278 }
261 279 $pricingRule->setMinimum( $minimum );
280 + $pricingRule->setMixAndMatchMinQuantity( $isMixAndMatch );
262 281 /*****************************************
263 282 *
264 283 * Services that modify pricing rule
265 284 *