n66n67
n66n67

Reputation: 31

WooCommerce hook into coupon validation by user meta

i'm searching for the hook where i can hook into the coupon validation during the checkout process.

Instead of validation by user's email address i would like to validate the coupon code by an user's meta field.

If the restricted coupon code matches the user meta field the discount is valid, otherwise coupon can't added to cart.

Which hook can i use?

Upvotes: 3

Views: 5204

Answers (2)

Hike Nalbandyan
Hike Nalbandyan

Reputation: 1056

The hook you are looking for is woocommerce_coupon_is_valid

It's a filter running after all default coupon validations.

Upvotes: 3

Vidish Purohit
Vidish Purohit

Reputation: 1078

You can use this hook : woocommerce_coupon_is_valid_for_product

You can get logged in user's information from wordpress and validate product there based on user meta information.

apply_filters( 'woocommerce_coupon_is_valid_for_product',  $false,  $product,  $instance,  $values ); 

It will give you 4 parameters when you implement it.

Upvotes: 2

Related Questions