Update review shipping options task complete logic (#33650)
* Update review shipping options task complete logic * Add changelog
This commit is contained in:
parent
2e167ca088
commit
88a66e6983
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: update
|
||||
|
||||
Update review shipping options task complete logic
|
|
@ -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' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue