This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Graduate draft orders #6288
Merged
Merged
Graduate draft orders #6288
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,20 +37,15 @@ public function __construct( Package $package ) { | |
* Set all hooks related to adding Checkout Draft order functionality to Woo Core. | ||
*/ | ||
public function init() { | ||
if ( $this->package->feature()->is_feature_plugin_build() ) { | ||
add_filter( 'wc_order_statuses', [ $this, 'register_draft_order_status' ] ); | ||
add_filter( 'woocommerce_register_shop_order_post_statuses', [ $this, 'register_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_valid_order_statuses_for_payment', [ $this, 'append_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'append_draft_order_post_status' ] ); | ||
// Hook into the query to retrieve My Account orders so draft status is excluded. | ||
add_action( 'woocommerce_my_account_my_orders_query', [ $this, 'delete_draft_order_post_status_from_args' ] ); | ||
add_action( 'woocommerce_cleanup_draft_orders', [ $this, 'delete_expired_draft_orders' ] ); | ||
add_action( 'admin_init', [ $this, 'install' ] ); | ||
} else { | ||
// Maybe remove existing cronjob if present because it shouldn't be needed in the environment. | ||
add_action( 'admin_init', [ $this, 'uninstall' ] ); | ||
} | ||
Comment on lines
-50
to
-53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this part and related things because we don't to remove cron jobs, this was a preventive workaround from the first accident around lost orders. |
||
add_filter( 'wc_order_statuses', [ $this, 'register_draft_order_status' ] ); | ||
add_filter( 'woocommerce_register_shop_order_post_statuses', [ $this, 'register_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_analytics_excluded_order_statuses', [ $this, 'append_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_valid_order_statuses_for_payment', [ $this, 'append_draft_order_post_status' ] ); | ||
add_filter( 'woocommerce_valid_order_statuses_for_payment_complete', [ $this, 'append_draft_order_post_status' ] ); | ||
// Hook into the query to retrieve My Account orders so draft status is excluded. | ||
add_action( 'woocommerce_my_account_my_orders_query', [ $this, 'delete_draft_order_post_status_from_args' ] ); | ||
add_action( 'woocommerce_cleanup_draft_orders', [ $this, 'delete_expired_draft_orders' ] ); | ||
add_action( 'admin_init', [ $this, 'install' ] ); | ||
} | ||
|
||
/** | ||
|
@@ -62,15 +57,6 @@ public function install() { | |
$this->maybe_create_cronjobs(); | ||
} | ||
|
||
/** | ||
* Remove cronjobs if they exist (but only from admin). | ||
* | ||
* @internal | ||
*/ | ||
public function uninstall() { | ||
$this->maybe_remove_cronjobs(); | ||
} | ||
|
||
/** | ||
* Maybe create cron events. | ||
*/ | ||
|
@@ -80,15 +66,6 @@ protected function maybe_create_cronjobs() { | |
} | ||
} | ||
|
||
/** | ||
* Unschedule cron jobs that are present. | ||
*/ | ||
protected function maybe_remove_cronjobs() { | ||
if ( function_exists( 'as_next_scheduled_action' ) && as_next_scheduled_action( 'woocommerce_cleanup_draft_orders' ) ) { | ||
as_unschedule_all_actions( 'woocommerce_cleanup_draft_orders' ); | ||
} | ||
} | ||
|
||
/** | ||
* Register custom order status for orders created via the API during checkout. | ||
* | ||
|
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.
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.
👏