woocommerce_coupon_get_apply_quantity

woocommerce_coupon_get_apply_quantity

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.8.7.0

apply_filters('woocommerce_coupon_get_apply_quantity') is found 4 times:

  • /includes/class-wc-discounts.php line 369
    			$price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : NumberUtil::round( $item->price );
    
    			// See how many and what price to apply to.
    			$apply_quantity    = $limit_usage_qty && ( $limit_usage_qty - $applied_count ) < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;
    			$apply_quantity    = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) );
    			$price_to_discount = ( $price_to_discount / $item->quantity ) * $apply_quantity;
    
    			// Run coupon calculations.
    			$discount = floor( $price_to_discount * ( $coupon_amount / 100 ) );
    
    			if ( is_a( $this->object, 'WC_Cart' ) && has_filter( 'woocommerce_coupon_get_discount_amount' ) ) {
    
  • /includes/class-wc-discounts.php line 433
     
    			// Run coupon calculations.
    			if ( $limit_usage_qty ) {
    				$apply_quantity = $limit_usage_qty - $applied_count < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;
    				$apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) );
    				$discount       = min( $amount, $item->price / $item->quantity ) * $apply_quantity;
    			} else {
    				$apply_quantity = apply_filters( 'woocommerce_coupon_get_apply_quantity', $item->quantity, $item, $coupon, $this );
    				$discount       = $amount * $apply_quantity;
    			}
    
    
  • /includes/class-wc-discounts.php line 436
    				$apply_quantity = $limit_usage_qty - $applied_count < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;
    				$apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) );
    				$discount       = min( $amount, $item->price / $item->quantity ) * $apply_quantity;
    			} else {
    				$apply_quantity = apply_filters( 'woocommerce_coupon_get_apply_quantity', $item->quantity, $item, $coupon, $this );
    				$discount       = $amount * $apply_quantity;
    			}
    
    			if ( is_a( $this->object, 'WC_Cart' ) && has_filter( 'woocommerce_coupon_get_discount_amount' ) ) {
    				// Send through the legacy filter, but not as cents.
    				$discount = wc_add_number_precision( apply_filters( 'woocommerce_coupon_get_discount_amount', wc_remove_number_precision( $discount ), wc_remove_number_precision( $price_to_discount ), $item->object, false, $coupon ) );
    
  • /includes/class-wc-discounts.php line 522
    			$price_to_discount = wc_remove_number_precision( ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price );
    
    			// See how many and what price to apply to.
    			$apply_quantity = $limit_usage_qty && ( $limit_usage_qty - $applied_count ) < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;
    			$apply_quantity = max( 0, apply_filters( 'woocommerce_coupon_get_apply_quantity', $apply_quantity, $item, $coupon, $this ) );
    
    			// Run coupon calculations.
    			$discount      = wc_add_number_precision( $coupon->get_discount_amount( $price_to_discount / $item->quantity, $item->object, true ) ) * $apply_quantity;
    			$discount      = wc_round_discount( min( $discounted_price, $discount ), 0 );
    			$applied_count = $applied_count + $apply_quantity;