Remove unnecessary renewal order paid date update #792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #791
Description
Back when we were working on WC 2.7 (which later became WC 3.0) we added some code to the
WC_Subscriptions_Renewal_Order::maybe_record_subscription_payment()
function which would set the renewal order's paid date to the current time.Based on the original commit message (515c8e2) this was necessary because the paid date was set consistently as it required the gateways to call the
payment_complete()
function.This is no longer necessary as WooCommerce core sets the paid date on status transition. See
WC_Order::set_status()
Given the
maybe_record_subscription_payment()
function is hooked onto a status transition hook, it's really not necessary for us to set the paid date.This PR:
$order->set_date_paid( $current_time )
call when a renewal order status is changed.Given we're no longer explicitly setting the paid date on a renewal order I did a review of the places where we use the paid date.
$subscription->get_date( 'last_order_date_paid' )
and it will return the paid date of the most recent order, however I wasn't able to find any cases where we do that.How to test this PR
Renewal order was paid @ 5:45 pm
trunk
the renewal order paid date would be updated.Renewal order was paid @ 5:50 pm
Product impact