diff --git a/facebook-commerce.php b/facebook-commerce.php index e0a6a6ae6..b19f6b758 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -68,6 +68,9 @@ class WC_Facebookcommerce_Integration extends WC_Integration { /** @var string the "enable product sync" setting ID */ const SETTING_ENABLE_PRODUCT_SYNC = 'wc_facebook_enable_product_sync'; + /** @var string the product description mode setting ID */ + const SETTING_FEED_FILE_GENERATION_ENABLED = 'wc_facebook_feed_file_generation_enabled'; + /** @var string the excluded product category IDs setting ID */ const SETTING_EXCLUDED_PRODUCT_CATEGORY_IDS = 'wc_facebook_excluded_product_category_ids'; @@ -3179,6 +3182,17 @@ public function is_product_sync_enabled() { return (bool) apply_filters( 'wc_facebook_is_product_sync_enabled', 'yes' === get_option( self::SETTING_ENABLE_PRODUCT_SYNC, 'yes' ), $this ); } + /** + * Determines whether feed file generation is enabled in Sync settings. + * + * @since 2.5.0 + * + * @return bool + */ + public function is_feed_file_generation_enabled() { + return (bool) ( 'yes' === get_option( self::SETTING_FEED_FILE_GENERATION_ENABLED, 'yes' ) ); + } + /** * Determines whether the scheduled re-sync is enabled. diff --git a/includes/Admin/Settings_Screens/Product_Sync.php b/includes/Admin/Settings_Screens/Product_Sync.php index 49d4c5cad..299abe2c9 100644 --- a/includes/Admin/Settings_Screens/Product_Sync.php +++ b/includes/Admin/Settings_Screens/Product_Sync.php @@ -318,6 +318,27 @@ public function get_settings() { ], [ 'type' => 'sectionend' ], + [ + 'name' => __( 'Feed File Settings', 'woocommerce' ), + 'type' => 'title', + 'id' => 'feed_file_settings', + ], + + [ + 'id' => \WC_Facebookcommerce_Integration::SETTING_FEED_FILE_GENERATION_ENABLED, + 'title' => __( 'Enable feed file generation.', 'facebook-for-woocommerce' ), + 'desc' => sprintf( + /* translators: url to documentation section. */ + __( 'Feed file is used for cyclic catalog content synchronization. Please check the documentation at %s to learn if this option should be enabled for your store.', 'facebook-for-woocommerce' ), + 'Feed File Settings', + ), + 'type' => 'checkbox', + 'label' => ' ', + 'default' => 'yes', + ], + + [ 'type' => 'sectionend', 'id' => 'feed_file_settings' ], + ]; } diff --git a/includes/Products/Feed.php b/includes/Products/Feed.php index fda2b95d1..8273f4c6d 100644 --- a/includes/Products/Feed.php +++ b/includes/Products/Feed.php @@ -162,7 +162,7 @@ public function schedule_feed_generation() { $integration = facebook_for_woocommerce()->get_integration(); // only schedule if configured - if ( ! $integration || ! $integration->is_configured() || ! $integration->is_product_sync_enabled() ) { + if ( ! $integration || ! $integration->is_configured() || ! $integration->is_product_sync_enabled() || ! $integration->is_feed_file_generation_enabled() ) { as_unschedule_all_actions( self::GENERATE_FEED_ACTION ); return; }