-
Notifications
You must be signed in to change notification settings - Fork 68
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
Cache get WC orders for incentives #10231
base: develop
Are you sure you want to change the base?
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.36 MB ℹ️ View Unchanged
|
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.
Thank you for handling this enhancement, @elazzabi! The code changes LGTM!
There is one thing we can do better: extend the caching period to almost 90 days. See how it is implemented in the WC core. Oh, and also include refunded orders (also see the WC core implementation).
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.
✅ LGTM - only code review
$has_orders = ! empty( | ||
wc_get_orders( | ||
[ | ||
'status' => [ 'wc-completed', 'wc-processing' ], |
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.
I think we could use the constants from OrderInternalStatus
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.
Hey 👋 I see that the class is in Core, so I think that's why we opted for hard coding the values 🤔
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.
Yeah. The OrderInternalStatus
class was introduced in Nov 2024. I don't think we can reliably jump on relying on it. This would make WooPayments incompatible with WC versions older than that.
@elazzabi, I don't have a strong opinion on matching the core implementation. Considering the "closer to core" goal, it wouldn't hurt to be as close as possible. But our Database Cache can handle it, no problems. I will leave it up to you to decide. |
@vladolaru Thanks! I would love to reduce the gap with Core, but I'm short on time at the moment. I will revisit it again if it's still open once I'm back 😄 |
Fixes #10046
Changes proposed in this Pull Request
This fix adds a caching layer when checking for orders as part of the incentives class. If orders are present, we cache for a longer period (1 week), if not, we cache for a shorter one (1 hour).
Testing instructions
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge