Update coupon amount after checkout


I have created custom coupons per logged in customers and set their initial amount to 0. After that by continuing customers to buy more they get i.e 10$ coupon amount increase that can be used in their next purchases. this way every custom coupon that belongs to that customer should be updated in every usage. In order to make them special per customer, I used customer email and also woocommerce_coupon_is_valid hook as follow:

add_filter( 'woocommerce_coupon_is_valid', 'coupon_is_valid', 10, 2);

function coupon_is_valid($result, $coupon){

    $restricted_emails = $coupon->get_email_restrictions();

    return ( in_array( wp_get_current_user()->user_email, $restricted_emails ) ? $result : false );

My problem here is that after applying coupon by customer its amount is not updated ( It should be decreased ). Is there any special woocommerce hook to update coupon after checkout?

Thanks in advance.

, Kourosh 3 years 2020-04-07T16:51:09-05:00 0 Answers 95 views 0

Leave an answer