ulc_codes_multiple_redemption_allowed
Filters whether multiple redemptions are allowed for a batch of coupon codes.
add_filter( 'ulc_codes_multiple_redemption_allowed', $callback, 10, 2 );
Description
Fires to determine if multiple redemptions of the same coupon code are allowed. Developers can filter this hook to override the default behavior, returning `false` to disallow multiple redemptions and `true` to permit them. The `$codes_batch_id` parameter is also provided for contextual checks.
Usage
add_filter( 'ulc_codes_multiple_redemption_allowed', 'your_function_name', 10, 2 );
Parameters
-
$is_allowed(mixed) - This parameter indicates whether multiple redemptions of the same code by the same user are allowed.
-
$codes_batch_id(mixed) - This parameter contains a boolean value indicating whether multiple redemptions of the same code are allowed.
Return Value
The filtered value.
Examples
// Example: Allow multiple redemptions for a specific codes batch ID.
add_filter( 'ulc_codes_multiple_redemption_allowed', function( $is_allowed, $codes_batch_id ) {
// Define the specific batch ID for which multiple redemptions should be allowed.
$specific_batch_id_to_allow_multiple = 'BATCH_XYZ_123';
// If the current codes batch ID matches our specific one, override the setting and allow multiple redemptions.
if ( $codes_batch_id === $specific_batch_id_to_allow_multiple ) {
return true;
}
// Otherwise, return the original allowed status.
return $is_allowed;
}, 10, 2 );
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/classes/helpers/class-database.php:1295
public static function is_multiple_redemption_allowed( $codes_batch_id = '' ) {
$is_allowed = AdminMenu::get_settings_value( Config::$uncanny_codes_same_code_user_redemption, 0, is_multisite() );
return apply_filters( 'ulc_codes_multiple_redemption_allowed', boolval( $is_allowed ), $codes_batch_id );
}