How to apply a custom coupon to a WooCommerce Subscription recurring amount?
I ned to create a custom coupon for use with WooCommerce Subscriptions because for some reason you can either have one on the sign up fee OR you have one on the recurring amount, but I need a coupon to be applied to both, but there is no option.
I have created a custom coupon using the filter woocommerce_coupon_discount_types, but the filter to then implement this coupon in the cart, woocommerce_coupon_get_discount_amount, does not add it to the recurring amounts, only adds it to the sign up fee.
How does one apply a coupon to the recurring fee?
function dhti_coupon_get_discount_amount($discount, $discounting_amount, $cart_item, $single, $coupon)
{
if ($coupon-discount_type == 'sign_up_and_recurring_percent')
{
$discount = $discounting_amount * $coupon-amount / 100;
return $discount;
}
else
{
return $discount;
}
}
add_filter('woocommerce_coupon_get_discount_amount', 'dhti_coupon_get_discount_amount', 10, 5);
Topic woocommerce-offtopic subscription Wordpress
Category Web