Skip to content

Hooks and Filters

The WPify Woo Feeds plugin provides hooks and filters to customize feed generation and product data.

Filter available feed modules.

apply_filters( 'wpify_woo_feeds_modules', array $modules );

Parameters:

  • $modules (array) — Array of feed module instances

Example — remove Alza feed module:

/**
* Remove Alza feed module
*
* @param array $modules Feed modules
* @return array
*/
function my_remove_alza_feed( $modules ) {
unset( $modules['feed_alza'] );
return $modules;
}
add_filter( 'wpify_woo_feeds_modules', 'my_remove_alza_feed' );

Filter product title in the feed.

apply_filters( 'wpify_woo_feeds_item_title', string $item_title, $product, $parent_product );

Parameters:

  • $item_title (string) — Product title
  • $product (object) — Product object
  • $parent_product (object|null) — Parent product (for variations)

Example — append shop name to title:

/**
* Append shop name to product title
*
* @param string $title Product title
* @param object $product Product
* @return string
*/
function my_feed_item_title( $title, $product ) {
return $title . ' | MyShop';
}
add_filter( 'wpify_woo_feeds_item_title', 'my_feed_item_title', 10, 2 );

Filter product name in the feed (alternative to title).

apply_filters( 'wpify_woo_feeds_item_name', string $item_name, $product, $parent_product );

Parameters:

  • $item_name (string) — Product name
  • $product (object) — Product object
  • $parent_product (object|null) — Parent product (for variations)

Filter the directory path where feed files are stored.

apply_filters( 'wpify_woo_feeds_dir_path', string $dir_path, string $feed_name, $feed );

Parameters:

  • $dir_path (string) — Default directory path
  • $feed_name (string) — Feed name
  • $feed (object) — Feed instance

These filters use the feed name as prefix (e.g., google_merchants_feed, heureka_cz_feed, zbozi_feed, alza_feed).

Filter which product IDs are included in the feed.

apply_filters( '{feed_name}_feed_product_ids', array $product_ids );

Example — exclude a specific product from Google Merchants feed:

/**
* Exclude product from Google Merchants feed
*
* @param array $product_ids Product IDs
* @return array
*/
function my_exclude_product_from_feed( $product_ids ) {
return array_diff( $product_ids, [ 123 ] );
}
add_filter( 'google_merchants_feed_feed_product_ids', 'my_exclude_product_from_feed' );

Filter feed data before XML generation.

apply_filters( '{feed_name}_feed_data', array $data, string $feed_name );

Parameters:

  • $data (array) — Feed data array
  • $feed_name (string) — Feed name

Skip individual products from a feed.

apply_filters( '{feed_name}_skip_product', bool $skip, $product, string $feed_name );

Parameters:

  • $skip (bool) — Whether to skip the product (default: false)
  • $product (object) — Product object
  • $feed_name (string) — Feed name

Example — skip products in hidden category:

/**
* Skip products in "hidden" category from Google Merchants feed
*
* @param bool $skip Whether to skip
* @param object $product Product
* @return bool
*/
function my_skip_hidden_products( $skip, $product ) {
if ( has_term( 'hidden', 'product_cat', $product->get_id() ) ) {
return true;
}
return $skip;
}
add_filter( 'google_merchants_feed_skip_product', 'my_skip_hidden_products', 10, 2 );

Override products per run for a specific feed.

apply_filters( '{feed_name}_products_per_run', int $products_per_run );

Example — reduce count for Google Merchants:

/**
* Process only 50 products per run for Google Merchants
*
* @param int $count Products per run
* @return int
*/
function my_feed_products_per_run( $count ) {
return 50;
}
add_filter( 'google_merchants_feed_products_per_run', 'my_feed_products_per_run' );

Filter the output feed file name.

apply_filters( '{feed_name}_feed_filename', string $filename, string $feed_name, $feed );

Parameters:

  • $filename (string) — Default file name (e.g., heureka_1.xml)
  • $feed_name (string) — Feed name
  • $feed (object) — Feed instance

Filter WooCommerce query arguments for fetching product IDs.

apply_filters( '{feed_name}_get_product_ids_args', array $args );

Parameters:

  • $args (array) — Arguments for wc_get_products() (limit, status, visibility, return)

Filter the data for individual items before they are written to the feed. Each feed has its own filter.

Example — add custom label to Google Merchants:

/**
* Add custom label for products on sale
*
* @param array $item Feed item data
* @param object $product Product
* @return array
*/
function my_google_custom_label( $item, $product ) {
if ( $product->is_on_sale() ) {
$item['custom_label_0'] = 'sale';
}
return $item;
}
add_filter( 'wpify_woo_feeds_google_merchants_item_data', 'my_google_custom_label', 10, 2 );

Example — replace WEBP images with JPG in Heureka feed:

/**
* Replace .webp extension with .jpg in Heureka feed image URLs
*
* @param array $data Feed item data
* @param object $product Product
* @return array
*/
function my_replace_webp_images( $data, $product ) {
foreach ( $data as $key => &$value ) {
if ( strpos( $key, 'IMGURL' ) !== false && is_array( $value ) && isset( $value['_cdata'] ) ) {
$value['_cdata'] = preg_replace( '/\.webp$/i', '.jpg', $value['_cdata'] );
}
}
return $data;
}
add_filter( 'wpify_woo_feeds_heureka_item_data', 'my_replace_webp_images', 10, 2 );

Available item data filters:

  • wpify_woo_feeds_google_merchants_item_data
  • wpify_woo_feeds_heureka_item_data
  • wpify_woo_feeds_zbozi_item_data
  • wpify_woo_feeds_alza_item_data
  • heureka_availability_item_data

Triggered before WP-CLI feed generation starts.

do_action( 'wpify_woo_feeds_cli_before_generate_feed', array $args, array $assoc_args );

Parameters:

  • $args (array) — WP-CLI positional arguments
  • $assoc_args (array) — WP-CLI associative arguments

You can add custom functions either in your child theme’s functions.php or use the Code Snippets plugin.