Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use WC built-in Action Scheduler to fetch in-app promotions (#45628)
* Use WC built-in ActionScheduler * Calling `WC_Admin_Marketplace_Promotions::init` immediately from `WC_Admin` constructor. `WC_Admin` is only instantiated in an admin request. If we init marketplace promotions from `woocommerce_init`, we'll be too late to add the callback for the scheduled action that fetches promotion data. * Changed transient life to 12 hours to match frequency of ActionScheduler action. * Changelog. * Updated `fetch_marketplace_promotions` to replace the transient every time it runs. This allows more frequent changes. * Added filter to allow promotions to be suppressed. * Fix indentation * More indentation fix * Clearing scheduled action if `woocommerce_marketplace_suppress_promotions` filter returns "true". * Running `clear_scheduled_event` on `init`. * WP_CLI check * We were including and instantiating `WC_Admin_Marketplace_Promotions` from the `WC_Admin` constructor. But `WC_Admin` is only instantiated during `is_admin` requests. We also need to respond to cron requests. So we're now including the class from `class-woocommerce.php` if the context is admin or cron, and instantiating it on `init`. This fixes the error in Scheduled Action `action failed via WP Cron: Scheduled action for woocommerce_marketplace_fetch_promotions will not be executed as no callbacks are registered.` * Linter errors. * Enhance append_bubble() method * introduce SCHEDULED_ACTION_INTERVAL * Make linter happier * Linter errors. --------- Co-authored-by: Remi Corson <1649788+corsonr@users.noreply.github.com> Co-authored-by: And Finally <andfinally@users.noreply.github.com>
- Loading branch information
1 parent
13ac914
commit 7c7ed0d
Showing
4 changed files
with
83 additions
and
55 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/fix-19763-marketplace-promotions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fix | ||
|
||
Using ActionScheduler to schedule fetching of in-app marketplace promotions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters