Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce option to disable feed file generation. #1874

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions facebook-commerce.php
Expand Up @@ -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';

Expand Down Expand Up @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions includes/Admin/Settings_Screens/Product_Sync.php
Expand Up @@ -318,6 +318,27 @@ public function get_settings() {
],
[ 'type' => 'sectionend' ],

[
'name' => __( 'Feed File Settings', 'woocommerce' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be sentence case.

Though we might want to review the UI for this - having it as a regular option in the UI may be confusing if we're trying to encourage merchants to turn it off.

'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' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we stick with a checkbox in UI for this, let's iterate on the wording to make it clear what we recommend. We can also use a tooltip to declutter the user interface.

'<a href="' . facebook_for_woocommerce()->get_documentation_url() . '#feed-file-settings">Feed File Settings</a>',
),
'type' => 'checkbox',
'label' => ' ',
'default' => 'yes',
],

[ 'type' => 'sectionend', 'id' => 'feed_file_settings' ],

];
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Products/Feed.php
Expand Up @@ -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;
}
Expand Down