-
Notifications
You must be signed in to change notification settings - Fork 37
Removing wc-checkout-draft status from the get related order IDs method #626
Removing wc-checkout-draft status from the get related order IDs method #626
Conversation
I haven't looked at the code or tested this yet but I had a general question. Does this mean the bug is only reproducible with the block Checkout and not when using the shortcode checkout? |
Hi Matt! For this part of the fix, yes. Still it would not be enough to fix the main issue (without the other PR). |
…et-related-order-ids
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.
@wjrosa I think this approach has some issues with it. I left a comment inline about why I think excluding the wc-checkout-draft
status from this function may be problematic.
I'm curious though. In the PR description you mention this:
The reason was that when calculating the switch fee, we were retrieving the last switch order, and that was including the current draft order (from the current checkout).
I wonder if we just need to exclude draft switch orders at that point, not from the cache.
…et-related-order-ids
… retrieving related orders
Oh Ok, James! I understand your concern. I decided to include a new param |
@wjrosa I don't think will work as intended. If you run this code snippet for example, it will return the newly created renewal order even though it has the checkout draft status. $subscription = wcs_get_subscription( 7634 );
$renewal_order = wcs_create_renewal_order( $subscription );
$renewal_order->set_status( 'wc-checkout-draft' );
$renewal_order->save();
echo $subscription->get_last_order( 'all', 'renewal', false ); This is because this PR introduces a new arg and then passes that arg all the way down to the cache level. WC_Subscription::get_last_order()
↳ WC_Subscription::get_related_order_ids()
↳ WCS_Related_Order_Store::get_related_order_ids()
↳ parent::get_related_order_ids() The problem is that So, because our cache is already populated, I'd recommend that we don't pass this arg that far down. IMO With all of that in mind, I don't think we should really pass this parameter down past Also, what do you think about broadening this param? Something like Let me know if that makes sense. 😅 I'm happy to work on an example. |
Thanks for the detailed argument, James! It makes total sense to me. I have updated the main implementation following your suggestion. I will update the woocommerce-subscriptions PR now to make use of it. |
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.
This looks pretty good @wjrosa, I've just left a couple of comments.
Co-authored-by: James Allan <[email protected]>
Co-authored-by: James Allan <[email protected]>
…et-related-order-ids
Thanks for the suggestions, James! I have accepted both and updated the branch with |
Fixes 4181-gh-woocommerce/woocommerce-subscriptions
Description
If a user upgrades their Subscription multiple times in a single month, the prices appear incorrectly calculated. This is happening since the introduction of the new order status:
wc-checkout-draft
(it was introduced with the blocks theme, more information here).The reason was that when calculating the switch fee, we were retrieving the last switch order, and that was including the current draft order (from the current checkout).
The fix filters the new status from the main method (
get_related_order_ids
).How to test this PR
trunk
, this signup fee will be calculated incorrectlyProduct impact