woocommerce_apply_individual_use_coupon

woocommerce_apply_individual_use_coupon

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

See hook in core

Displaying hooks found in version: woocommerce.8.7.0

apply_filters('woocommerce_apply_individual_use_coupon') is found 2 times:

  • /includes/class-wc-cart.php line 1774
    		}
    
    		// If its individual use then remove other coupons.
    		if ( $the_coupon->get_individual_use() ) {
    			$coupons_to_keep = apply_filters( 'woocommerce_apply_individual_use_coupon', array(), $the_coupon, $this->applied_coupons );
    
    			foreach ( $this->applied_coupons as $applied_coupon ) {
    				$keep_key = array_search( $applied_coupon, $coupons_to_keep, true );
    				if ( false === $keep_key ) {
    					$this->remove_coupon( $applied_coupon );
    				} else {
    
  • /src/StoreApi/Utilities/CartController.php line 989
    			 * @param \WC_Coupon $coupon Coupon object applied to the cart.
    			 * @param array $applied_coupons Array of applied coupons already applied to the cart.
    			 * @return array
    			 */
    			$coupons_to_remove = array_diff( $applied_coupons, apply_filters( 'woocommerce_apply_individual_use_coupon', array(), $coupon, $applied_coupons ) );
    
    			foreach ( $coupons_to_remove as $code ) {
    				$cart->remove_coupon( $code );
    			}
    
    			$applied_coupons = array_diff( $applied_coupons, $coupons_to_remove );