Skip to main content

How to change the visibility of articles within a variant

When using the Grouped Products feature in our WooCommerce integration, child articles (the individual variations) are typically excluded from the main catalog to avoid clutter. However, you may want to customize this behavior.

Default Behavior

By default, StoreLinkr sets the visibility of child articles to search. This means they:

  • Do not appear on category pages.
  • Do appear in search results.
  • Do appear as linked items within the Grouped Product.

Customizing Visibility via Filters

Developers can use the storelinkr_single_visibility filter to programmatically change this status. This is useful if you want certain items to remain completely hidden or fully visible in the catalog based on specific conditions (e.g., stock level or category).

Example Code Snippet

Add this to your functions.php:

add_filter('storelinkr_single_visibility', 'custom_storelinkr_visibility', 10, 2);

/**
* Adjust product visibility based on conditions.
*
* @param string $visibility Current visibility ('visible', 'catalog', 'search', or 'hidden').
* @param int $product_id The WordPress Product ID.
* @return string The modified visibility.
*/
function custom_storelinkr_visibility($visibility, $product_id) {
// Example: Hide a specific product completely
if ($product_id == 123) {
return 'hidden';
}

// Example: Make everything fully visible in the catalog
// return 'visible';

return $visibility;
}

Supported Visibility Values

These correspond to standard WooCommerce visibility states:

  • visible: Visible everywhere (catalog and search).
  • catalog: Visible only in the catalog/category pages.
  • search: Visible only in search results (StoreLinkr default for child products).
  • hidden: Completely hidden from the frontend.

Testing Changes

Visibility changes are applied during the synchronization process. If you update your code:

  1. Wait for the next scheduled sync.
  2. OR, trigger a manual sync for the specific variant from the StoreLinkr Portal to see the changes immediately.