From cb2048004cf1f2ac92b063b7f8283554567963a0 Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Fri, 13 Jan 2023 16:02:28 +0100 Subject: [PATCH 1/9] Add the Cart & Checkout Blocks as a feature --- .../woocommerce/src/Internal/Features/FeaturesController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index bf2622df5c2..8a014af58a7 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -105,6 +105,11 @@ class FeaturesController { 'description' => __( 'Enable the high performance order storage feature.', 'woocommerce' ), 'is_experimental' => true, ), + 'cart_checkout_blocks' => array( + 'name' => __( 'Cart & Checkout Blocks', 'woocommerce' ), + 'description' => __( 'Optimize for faster checkout', 'woocommerce' ), + 'is_experimental' => false, + ), ); $this->legacy_feature_ids = array( 'analytics', 'new_navigation' ); From c42fdb039c6f7b56ade6c91fbe133e9793e885ae Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Fri, 13 Jan 2023 16:05:40 +0100 Subject: [PATCH 2/9] Prevent displaying UI setting of the C&C Blocks Currently, we don't desire displaying the C&C Blocks feature's settings. We may choose otherwise in the future, but for the time being adding the C&C Block to the list of features does the work! --- .../woocommerce/src/Internal/Features/FeaturesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index 8a014af58a7..44f84e1a77a 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -540,7 +540,7 @@ class FeaturesController { return $features[ $feature_id ]['is_experimental']; } ); - $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids ); + $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, [ 'cart_checkout_blocks' ] ); $feature_ids = array_merge( $mature_feature_ids, array( 'mature_features_end' ), $experimental_feature_ids ); foreach ( $feature_ids as $id ) { From 728ba16b350780577b5789ef1c48124736457805 Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Fri, 13 Jan 2023 16:16:26 +0100 Subject: [PATCH 3/9] Add a change file --- ...d-36413-support-for-cart-checkout-in-declare-compatibility | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/woocommerce/changelog/add-36413-support-for-cart-checkout-in-declare-compatibility diff --git a/plugins/woocommerce/changelog/add-36413-support-for-cart-checkout-in-declare-compatibility b/plugins/woocommerce/changelog/add-36413-support-for-cart-checkout-in-declare-compatibility new file mode 100644 index 00000000000..7724faa14f5 --- /dev/null +++ b/plugins/woocommerce/changelog/add-36413-support-for-cart-checkout-in-declare-compatibility @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Add the support for the C&C Blocks in declaring compatibility feature From 4059fbb33ba08f949bcc12835f00b45479a2cac6 Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Mon, 16 Jan 2023 09:57:06 +0100 Subject: [PATCH 4/9] Fix PHPCS lint error: short array syntax --- .../woocommerce/src/Internal/Features/FeaturesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index 44f84e1a77a..47694ded9a3 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -540,7 +540,7 @@ class FeaturesController { return $features[ $feature_id ]['is_experimental']; } ); - $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, [ 'cart_checkout_blocks' ] ); + $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, array( 'cart_checkout_blocks' ) ); $feature_ids = array_merge( $mature_feature_ids, array( 'mature_features_end' ), $experimental_feature_ids ); foreach ( $feature_ids as $id ) { From 390efe8bdd36264e8eae7d415a6e616d02673bf4 Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Wed, 22 Feb 2023 19:05:52 +0100 Subject: [PATCH 5/9] Fix PHPCS lint error --- .../woocommerce/src/Internal/Features/FeaturesController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index 47694ded9a3..d623021dc85 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -105,7 +105,7 @@ class FeaturesController { 'description' => __( 'Enable the high performance order storage feature.', 'woocommerce' ), 'is_experimental' => true, ), - 'cart_checkout_blocks' => array( + 'cart_checkout_blocks' => array( 'name' => __( 'Cart & Checkout Blocks', 'woocommerce' ), 'description' => __( 'Optimize for faster checkout', 'woocommerce' ), 'is_experimental' => false, From b5b0c28ed0a9118216c8ce62ae6b75574ee5774a Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Thu, 23 Feb 2023 08:37:05 +0100 Subject: [PATCH 6/9] Add generic approach to adding features without UI In our case for the Cart & Checkout feature, we don't want to show the UI in the "Features" tab in Woo Settings. Creating a flag for this purpose will make it easier for future features to unsubscribe from showing a UI if required --- .../src/Internal/Features/FeaturesController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index d623021dc85..aa6803e87b8 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -94,21 +94,25 @@ class FeaturesController { 'description' => __( 'Enables WooCommerce Analytics', 'woocommerce' ), 'is_experimental' => false, 'enabled_by_default' => true, + 'disable_ui' => false, ), 'new_navigation' => array( 'name' => __( 'Navigation', 'woocommerce' ), 'description' => __( 'Adds the new WooCommerce navigation experience to the dashboard', 'woocommerce' ), 'is_experimental' => false, + 'disable_ui' => false, ), 'custom_order_tables' => array( 'name' => __( 'High-Performance order storage (COT)', 'woocommerce' ), 'description' => __( 'Enable the high performance order storage feature.', 'woocommerce' ), 'is_experimental' => true, + 'disable_ui' => false, ), 'cart_checkout_blocks' => array( 'name' => __( 'Cart & Checkout Blocks', 'woocommerce' ), 'description' => __( 'Optimize for faster checkout', 'woocommerce' ), 'is_experimental' => false, + 'disable_ui' => true, ), ); @@ -540,7 +544,13 @@ class FeaturesController { return $features[ $feature_id ]['is_experimental']; } ); - $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, array( 'cart_checkout_blocks' ) ); + $disabled_ui_feature_ids = array_filter( + $feature_ids, + function( $feature_id ) use ( $features ) { + return $features[ $feature_id ]['disable_ui']; + } + ); + $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, $disabled_ui_feature_ids ); $feature_ids = array_merge( $mature_feature_ids, array( 'mature_features_end' ), $experimental_feature_ids ); foreach ( $feature_ids as $id ) { From b312c65a95d8f0c217ecda37c039cca42203091e Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Thu, 23 Feb 2023 08:59:19 +0100 Subject: [PATCH 7/9] Fix PHPCS errors --- .../woocommerce/src/Internal/Features/FeaturesController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index 604c573b025..e3ee40b993c 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -554,12 +554,12 @@ class FeaturesController { return $features[ $feature_id ]['is_experimental']; } ); - $disabled_ui_feature_ids = array_filter( + $disabled_ui_feature_ids = array_filter( $feature_ids, function( $feature_id ) use ( $features ) { return $features[ $feature_id ]['disable_ui']; } - ); + ); $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, $disabled_ui_feature_ids ); $feature_ids = array_merge( $mature_feature_ids, array( 'mature_features_end' ), $experimental_feature_ids ); From 615365d14e0e2b944f05213e366fd1a9849612db Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Thu, 23 Feb 2023 11:31:01 +0100 Subject: [PATCH 8/9] Fix "undefined `disable_ui` index" error --- plugins/woocommerce/src/Internal/Features/FeaturesController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index e3ee40b993c..fbbf4a456b9 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -107,6 +107,7 @@ class FeaturesController { 'name' => __( 'New product editor', 'woocommerce' ), 'description' => __( 'Try the new product editor (Beta)', 'woocommerce' ), 'is_experimental' => true, + 'disable_ui' => false, ), 'custom_order_tables' => array( 'name' => __( 'High-Performance order storage (COT)', 'woocommerce' ), From e6bee7b785416f0d70859b8eba4a7ada9d68c55b Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Thu, 2 Mar 2023 10:39:33 +0100 Subject: [PATCH 9/9] Apply disable UI filter to experimental features too This change disable UI for both experimental and mature features Previously we applied this filter to mature ones only --- .../src/Internal/Features/FeaturesController.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index fbbf4a456b9..8011280ec2b 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -555,13 +555,7 @@ class FeaturesController { return $features[ $feature_id ]['is_experimental']; } ); - $disabled_ui_feature_ids = array_filter( - $feature_ids, - function( $feature_id ) use ( $features ) { - return $features[ $feature_id ]['disable_ui']; - } - ); - $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids, $disabled_ui_feature_ids ); + $mature_feature_ids = array_diff( $feature_ids, $experimental_feature_ids ); $feature_ids = array_merge( $mature_feature_ids, array( 'mature_features_end' ), $experimental_feature_ids ); foreach ( $feature_ids as $id ) { @@ -593,6 +587,10 @@ class FeaturesController { continue; } + if ( isset( $features[ $id ]['disable_ui'] ) && $features[ $id ]['disable_ui'] ) { + continue; + } + $feature_settings[] = $this->get_setting_for_feature( $id, $features[ $id ], $admin_features_disabled ); }