-
Notifications
You must be signed in to change notification settings - Fork 37
Now zero dollar subscriptions won't trigger renawal emails anymore #796
Conversation
4264748
to
977b87c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good.
- I confirmed that the action is removed for free subscriptions.
trunk |
This branch |
---|---|
![]() |
![]() |
- I confirmed that subscriptions with a recurring total still include the action and it still works (ie sends the email).
- Confirmed that subscriptions with a recurring total still sends the email via AS. *
- Confirmed that free subscriptions don't send the email via AS. *
* To test the emails are and aren't sent in a normal scenario I used this code snippet to simulate a renewal that is due in 3 days + 10 seconds. ie the email should send in 10 seconds.
wcs_get_subscription( 466 )->update_dates( [
'next_payment' => gmdate( 'Y-m-d H:i:s', time() + ( 3 * DAY_IN_SECONDS ) + 10 ),
] );
I left a small comment about the changelog entry.
Co-authored-by: James Allan <[email protected]>
@@ -156,6 +156,9 @@ public static function send_notification( $subscription_id ) { | |||
switch ( current_action() ) { | |||
case 'woocommerce_scheduled_subscription_customer_notification_renewal': | |||
$subscription = wcs_get_subscription( $subscription_id ); | |||
if ( $subscription->get_total() <= 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why <= 0
? Is there ever a case where we have a negative subscription? And if so, is that a refund? And if so, should we break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why <= 0? Is there ever a case where we have a negative subscription?
The only way for the subscription totals to be negative in that flow is if the merchant sets a bigger discount than the product price in the admin area and then select Send upcoming renewal notification
and click update order.

And if so, is that a refund?
Subscriptions can't really be refunded what gets refunded are orders and orders don't have the Send upcoming renewal notification
option so that flow would never run when refunding.
I've also tested coupons and they only discount up to 100% of the cart/order total.
Even products with negative price end up creating a subscriptions with a $0 total though the order has a negative total
Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4778
Description
This PR adds a check to prevent sending renewal reminders for 0 dollar orders
How to test this PR
Send upcoming renewal notification
option does not show up in the order actions select boxManual renewal notice
email but you do receive aThank you for your order
emailProduct impact