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.9.8.1

apply_filters('woocommerce_apply_individual_use_coupon') is found 2 times:

  • /includes/class-wc-cart.php line 1787
    1783
    1784
    1785
    1786
    1787
    1788
    1789
    1790
    1791
    1792
    1793
    }
     
    // 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 1054
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    * @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 );