PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.17
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.17
1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 All 180 releases
← All changes | app/Intents/IntentHelper.php +29 -0 1.4.161.4.17 View file →
@@ -493,8 +493,37 @@
493 493 }
494 494
495 495 $discountable_units = $this->grouped_discount_budget( $rule, $total_qualifying_units );
496 496
497 + /**
498 + * A flat amount is charged for the pooled group as a whole.
499 + *
500 + * Pooling exists so the cart together can reach the tier minimum, so
501 + * the rule qualifies for the group rather than for each line that
502 + * contributed quantity. The Calc layer returns the rule value whole
503 + * for every line it is handed, because a flat amount does not scale
504 + * with units, so spreading it across lines multiplied the discount by
505 + * the line count: a flat 10 came out as 20 over two lines.
506 + *
507 + * It is applied to the first eligible line carrying the entire pooled
508 + * budget, which is what lets a recursive rule still charge once per
509 + * bundle: the Calc layer derives the bundle count from that quantity.
510 + * Per unit types keep every line, since their amount is meant to
511 + * scale with the units.
512 + */
513 + if ( in_array( $rule['discount_type'], array( 'fixed', 'fixed_price' ), true ) ) {
514 + $first_line = reset( $eligible_lines );
515 +
516 + if ( ! empty( $first_line['item'] ) && $discountable_units > 0 ) {
517 + $item = $first_line['item'];
518 + $item['disco_forced_qty'] = $discountable_units;
519 +
520 + $this->apply_rule_to_discount( $discounts, $campaign, $rule, $item, $cart, $total_applicable_qty );
521 + }
522 +
523 + continue;
524 + }
525 +
497 526 // Hand out the discountable units across the eligible lines in cart order.
498 527 foreach ( $eligible_lines as $eligible_line ) {
499 528 if ( $discountable_units <= 0 ) {
500 529 break;