Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions includes/Admin/Enhanced_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ];
}
Expand Down Expand Up @@ -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,
)
);

Expand Down
23 changes: 23 additions & 0 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -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' ),
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion includes/Admin/Settings_Screens/Product_Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 10 additions & 8 deletions includes/RolloutSwitches.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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,
)
);
}
Expand Down