← All changes
|
src/Addons/AdvancedQuantityOptions/QuantityManager.php
+5
-1
6.5.0
→
8.0.2
View file →
| @@ -76,9 +76,13 @@ | ||
| 76 | 76 | $groupOf = $pricingRule->data['group_of_quantity'] ?? null; |
| 77 | 77 | |
| 78 | 78 | if ( $max ) { |
| 79 | 79 | |
| 80 | - if ( ! is_cart() && ! is_checkout() ) { | |
| 80 | + // Subtract what is already in the cart ONLY for the classic product-page input, where | |
| 81 | + // the field means "how many more can be added". The Store API reads this filter's | |
| 82 | + // max_value as the ABSOLUTE cart maximum (QuantityLimits::get_add_to_cart_limits), so | |
| 83 | + // subtracting there double-counts the cart and caps customers at half the real limit. | |
| 84 | + if ( ! is_cart() && ! is_checkout() && ! WC()->is_rest_api_request() ) { | |
| 81 | 85 | $max = max( 1, $max - $this->getProductCartQuantity( $product->get_id() ) ); |
| 82 | 86 | } |
| 83 | 87 | |
| 84 | 88 | $max = max( $groupOf, $max ); |