Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Apply Coupon To Exisitng Subscriber › Reply To: Apply Coupon To Exisitng Subscriber

#15615
Heidi Maskelyne
Participant

Hi again ,

I know we can hook into renewals below code which is good but how can I check through all coupons to see if the subscriber has a valid coupon to use ?

function apply_discount_on_renewal_order_created( $renewal_order, $subscription ) {
    $order           = new WC_Order( $renewal_order->get_id() );
    $coupon_amount   = 25;
    $order->set_total( $order->get_total() - $coupon_amount );
    return $order;
}
add_filter( 'wcs_renewal_order_created', 'apply_discount_on_renewal_order_created', 10, 2 );