Update review shipping options task complete logic (#33650)

* Update review shipping options task complete logic

* Add changelog
This commit is contained in:
Chi-Hsuan Huang 2022-06-29 15:34:09 +08:00 committed by GitHub
parent 2e167ca088
commit 88a66e6983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Update review shipping options task complete logic

View File

@ -8,6 +8,16 @@ use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
* Review Shipping Options Task
*/
class ReviewShippingOptions extends Task {
/**
* Constructor
*
* @param TaskList $task_list Parent task list.
*/
public function __construct( $task_list ) {
parent::__construct( $task_list );
add_action( 'current_screen', array( $this, 'possibly_mark_task_as_completed' ) );
}
/**
* ID.
*
@ -70,4 +80,26 @@ class ReviewShippingOptions extends Task {
public function get_action_url() {
return admin_url( 'admin.php?page=wc-settings&tab=shipping' );
}
/**
* Mark task as completed when the user visits the shipping setting page.
*/
public function possibly_mark_task_as_completed() {
$screen = get_current_screen();
if (
! $screen ||
'woocommerce_page_wc-settings' !== $screen->id ||
! isset( $_GET['tab'] ) || 'shipping' !== $_GET['tab'] // phpcs:ignore CSRF okok.
) {
// It's not the shipping settings page.
return;
}
if ( self::is_complete() || ! self::can_view() ) {
return;
}
update_option( 'woocommerce_admin_reviewed_default_shipping_zones', 'yes' );
}
}