Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing get_posts with wc_get_orders #719

Merged
merged 6 commits into from
Nov 12, 2024

Conversation

wjrosa
Copy link
Contributor

@wjrosa wjrosa commented Nov 8, 2024

Fixes 2248-gh-woocommerce/woocommerce-subscriptions

Description

This PR replaces the usage of the function get_posts with wc_get_orders to improve performance. To do that, I have updated all the parameters accordingly.

How to test this PR

Code review. Check if the tests are still passing.

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes
  • Will this PR affect WooCommerce Payments? yes
  • Added deprecated functions, hooks or classes to the spreadsheet

@wjrosa wjrosa self-assigned this Nov 8, 2024
@wjrosa wjrosa requested a review from mattallan November 8, 2024 19:48
Copy link
Contributor

@mattallan mattallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @wjrosa I'm sorry to say but these functions will no longer be used and will be deprecated once we merge #163 so I don't think we need to update them 😢 Sorry!

I think we can also ignore the get_posts() used in wcs_get_subscription_id_from_key() as it's an old helper function from back when a subscription object used to be an array of data stored in order meta (stored in meta {$order_id}_{$product_id} which we referred to as a subscriptions key) 🙈

I guess it technically still works and it's not a deprecated helper 🤷 So maybe it's fine for us to update it? Although, just above this get_posts() is a direct posts table query so we'd need to update that as well.

I'll leave it up to you if you want to update it or close this PR entirely.

If we do decide to leave it, we should probably add an inline comment in case someone stumbles upon this get_posts() and has questions xD

@wjrosa
Copy link
Contributor Author

wjrosa commented Nov 11, 2024

Hey @wjrosa I'm sorry to say but these functions will no longer be used and will be deprecated once we merge #163 so I don't think we need to update them 😢 Sorry!

I think we can also ignore the get_posts() used in wcs_get_subscription_id_from_key() as it's an old helper function from back when a subscription object used to be an array of data stored in order meta (stored in meta {$order_id}_{$product_id} which we referred to as a subscriptions key) 🙈

I guess it technically still works and it's not a deprecated helper 🤷 So maybe it's fine for us to update it? Although, just above this get_posts() is a direct posts table query so we'd need to update that as well.

I'll leave it up to you if you want to update it or close this PR entirely.

If we do decide to leave it, we should probably add an inline comment in case someone stumbles upon this get_posts() and has questions xD

No worries! Thanks for letting me know. I have just added the comment above the get_posts call instead and removed the changelog entry 👍

@wjrosa wjrosa requested a review from mattallan November 11, 2024 14:07
Copy link
Contributor

@mattallan mattallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wjrosa for the latest changes! Approving this :)

@wjrosa wjrosa merged commit cd8ef33 into trunk Nov 12, 2024
9 checks passed
@wjrosa wjrosa deleted the dev/replacing-get-posts-with-wc-get-orders branch November 12, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants