diff --git a/includes/Admin/Enhanced_Settings.php b/includes/Admin/Enhanced_Settings.php index 1e2063151..26bf6c171 100644 --- a/includes/Admin/Enhanced_Settings.php +++ b/includes/Admin/Enhanced_Settings.php @@ -72,14 +72,27 @@ public function __construct( \WC_Facebookcommerce $plugin ) { * @return array */ public function build_menu_item_array(): array { - $is_connected = $this->plugin->get_connection_handler()->is_connected(); + $is_connected = $this->plugin->get_connection_handler()->is_connected(); + $is_woo_all_products_sync_enbaled = $this->plugin->get_rollout_switches()->is_switch_enabled( + RolloutSwitches::SWITCH_WOO_ALL_PRODUCTS_SYNC_ENABLED + ); if ( $is_connected ) { - // TODO: Remove Product sync and Product sets tab once catalog changes are complete - $screens = array( - Settings_Screens\Shops::ID => new Settings_Screens\Shops(), - Settings_Screens\Product_Sets::ID => new Settings_Screens\Product_Sets(), - ); + if ( $is_woo_all_products_sync_enbaled ) { + $screens = array( + Settings_Screens\Shops::ID => new Settings_Screens\Shops(), + Settings_Screens\Product_Sets::ID => new Settings_Screens\Product_Sets(), + ); + } else { + /** + * If not enabled then the product sync tab should show itself + */ + $screens = array( + Settings_Screens\Shops::ID => new Settings_Screens\Shops(), + Settings_Screens\Product_Sync::ID => new Settings_Screens\Product_Sync(), + Settings_Screens\Product_Sets::ID => new Settings_Screens\Product_Sets(), + ); + } } else { $screens = [ Settings_Screens\Shops::ID => new Settings_Screens\Shops() ]; } @@ -192,9 +205,9 @@ public function render() { 'flow_step' => $current_tab . '_tab_rendered', ), array( - 'should_send_log_to_meta' => true, + 'should_send_log_to_meta' => true, 'should_save_log_in_woocommerce' => true, - 'woocommerce_log_level' => \WC_Log_Levels::DEBUG, + 'woocommerce_log_level' => \WC_Log_Levels::DEBUG, ) ); diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index 1bbf67913..03ae31bb4 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -90,6 +90,16 @@ public function add_extra_screens(): void { if ( true === $is_connected && true === $is_whatsapp_utility_messaging_enabled ) { $this->screens[ Settings_Screens\Whatsapp_Utility::ID ] = new Settings_Screens\Whatsapp_Utility(); } + + $is_woo_all_products_sync_enbaled = $this->plugin->get_rollout_switches()->is_switch_enabled( + RolloutSwitches::SWITCH_WOO_ALL_PRODUCTS_SYNC_ENABLED + ); + /** + * If all products sync is not enabled should show the Product sync tab + */ + if ( true === $is_connected && false === $is_woo_all_products_sync_enbaled ) { + $this->screens[ Settings_Screens\Product_Sync::ID ] = new Settings_Screens\Product_Sync(); + } } /** @@ -171,6 +181,10 @@ public function is_marketing_enabled() { * @param string $screen_id the ID to connect to */ private function connect_to_enhanced_admin( $screen_id ) { + $is_woo_all_products_sync_enbaled = $this->plugin->get_rollout_switches()->is_switch_enabled( + RolloutSwitches::SWITCH_WOO_ALL_PRODUCTS_SYNC_ENABLED + ); + if ( is_callable( 'wc_admin_connect_page' ) ) { $crumbs = array( __( 'Facebook for WooCommerce', 'facebook-for-woocommerce' ), @@ -182,6 +196,15 @@ private function connect_to_enhanced_admin( $screen_id ) { case Connection::ID: $crumbs[] = __( 'Connection', 'facebook-for-woocommerce' ); break; + case Settings_Screens\Product_Sync::ID: + /** + * If all proudcts sync not enabled + * Show the product sync tab + */ + if ( ! $is_woo_all_products_sync_enbaled ) { + $crumbs[] = __( 'Product sync', 'facebook-for-woocommerce' ); + } + break; case Settings_Screens\Advertise::ID: $crumbs[] = __( 'Advertise', 'facebook-for-woocommerce' ); break; diff --git a/includes/Admin/Settings_Screens/Product_Sync.php b/includes/Admin/Settings_Screens/Product_Sync.php index e4f68b040..8893a7bc8 100644 --- a/includes/Admin/Settings_Screens/Product_Sync.php +++ b/includes/Admin/Settings_Screens/Product_Sync.php @@ -20,9 +20,10 @@ /** * The Product Sync settings screen object. + * * * * @deprecated - * From version 3.5.1 onwards product sync tab will no longer be used across the app and should be + * From version 3.5.3 onwards product sync tab will no longer be used across the app and should be * removed from existence after WooAllProducts happen. */ class Product_Sync extends Abstract_Settings_Screen { diff --git a/includes/RolloutSwitches.php b/includes/RolloutSwitches.php index 5d7caa396..c3456bffa 100644 --- a/includes/RolloutSwitches.php +++ b/includes/RolloutSwitches.php @@ -24,15 +24,17 @@ class RolloutSwitches { /** @var \WC_Facebookcommerce commerce handler */ private \WC_Facebookcommerce $plugin; - public const SWITCH_ROLLOUT_FEATURES = 'rollout_enabled'; - public const WHATSAPP_UTILITY_MESSAGING = 'whatsapp_utility_messages_enabled'; - public const SWITCH_PRODUCT_SETS_SYNC_ENABLED = 'product_sets_sync_enabled'; - private const SETTINGS_KEY = 'wc_facebook_for_woocommerce_rollout_switches'; + public const SWITCH_ROLLOUT_FEATURES = 'rollout_enabled'; + public const WHATSAPP_UTILITY_MESSAGING = 'whatsapp_utility_messages_enabled'; + public const SWITCH_PRODUCT_SETS_SYNC_ENABLED = 'product_sets_sync_enabled'; + public const SWITCH_WOO_ALL_PRODUCTS_SYNC_ENABLED = 'woo_all_products_sync_enabled'; + private const SETTINGS_KEY = 'wc_facebook_for_woocommerce_rollout_switches'; private const ACTIVE_SWITCHES = array( self::SWITCH_ROLLOUT_FEATURES, self::WHATSAPP_UTILITY_MESSAGING, self::SWITCH_PRODUCT_SETS_SYNC_ENABLED, + self::SWITCH_WOO_ALL_PRODUCTS_SYNC_ENABLED, ); public function __construct( \WC_Facebookcommerce $plugin ) { @@ -82,13 +84,13 @@ public function init() { Logger::log( $e->getMessage(), array( - 'flow_name' => 'rollout_switches', - 'flow_step' => 'init', + 'flow_name' => 'rollout_switches', + 'flow_step' => 'init', ), array( - 'should_send_log_to_meta' => true, + 'should_send_log_to_meta' => true, 'should_save_log_in_woocommerce' => true, - 'woocommerce_log_level' => \WC_Log_Levels::ERROR, + 'woocommerce_log_level' => \WC_Log_Levels::ERROR, ) ); }