Filter uncanny-automator

acfw_filter_amount

Filters the coupon amount for a specific user before it's applied.

add_filter( 'acfw_filter_amount', $callback, 10, 1 );

Description

Filters the amount of store credit for a customer. Allows developers to modify the calculated store credit balance before it's used. Fires when retrieving a customer's current store credit balance. Use this hook to adjust the balance for custom logic or reporting.


Usage

add_filter( 'acfw_filter_amount', 'your_function_name', 10, 1 );

Parameters

$user_id (mixed)
This parameter contains the ID of the user whose balance is being retrieved or filtered.

Return Value

The filtered value.


Examples

/**
 * Example: Reduce the displayed store credit amount by 10% for a specific user.
 *
 * This filter allows modification of the store credit amount calculated by the
 * Advanced Coupons for WooCommerce plugin.
 */
add_filter( 'acfw_filter_amount', function( $amount, $user_id ) {
    // Only apply the discount for a specific user, e.g., user ID 123
    if ( $user_id == 123 ) {
        // Reduce the amount by 10%
        $discount = $amount * 0.10;
        $amount -= $discount;
    }

    // Return the (potentially modified) amount
    return $amount;
}, 10, 2 ); // Priority 10, accepts 2 arguments ($amount, $user_id)

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/advanced-coupons/helpers/advanced-coupons-helpers.php:66
src/integrations/advanced-coupons/helpers/advanced-coupons-helpers.php:94

public function get_current_balance_of_the_customer( $user_id ) {
		if ( empty( $user_id ) || 0 === $user_id ) {
			return 0;
		}

		return apply_filters( 'acfw_filter_amount', ACFWF()->Store_Credits_Calculate->get_customer_balance( $user_id ) );
	}

Scroll to Top