Use WordPress filters to customize the XML that Google Product Feed sends to Google Merchant Center. These examples apply to the standard Google product feed in version 12.3.1. Test one change at a time in a site-specific plugin on a test store. Open the generated feed and compare a simple product and a variation with the storefront before making the same change on a live store.
Note:
This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.
Use the short product description
↑ Back to topGo to WooCommerce → Settings → Product Feeds. For Description, choose Main product description (short preferred) plus variation description or Main product description only (short preferred). The default is Main product description (full preferred) plus variation description.
Customize the product description
↑ Back to topThe filter receives the feed item and its WooCommerce product or variation. This example uses a plain-text google_feed_description custom field when it contains a value.
add_filter( 'woocommerce_gpf_feed_item_google', function ( $item, $product ) {
$value = $product->get_meta( 'google_feed_description' );
$text = is_string( $value ) ? trim( wp_strip_all_tags( $value ) ) : '';
if ( '' !== $text ) {
$item->description = $text;
}
return $item;
}, 10, 2 );
Populate the feed with custom values
↑ Back to topUse woocommerce_gpf_elements_google to override Google feed attributes. The filter receives the parent product ID and a variation ID when there is one. This example uses the supplier_brand_name custom field on the item.
add_filter( 'woocommerce_gpf_elements_google', function ( $elements, $id, $variation_id ) {
$product = wc_get_product( $variation_id ?? $id );
if ( ! $product ) {
return $elements;
}
$brand = $product->get_meta( 'supplier_brand_name' );
if ( is_string( $brand ) && '' !== trim( $brand ) ) {
$elements['brand'] = array( trim( $brand ) );
}
return $elements;
}, 11, 3 );
Use woocommerce_gpf_feed_item_google for properties on the feed item itself. A price integration must keep the regular and sale prices, their tax-inclusive and tax-exclusive values, and the final price consistent. Compare each exported price to the price customers see on the corresponding landing page. Google price requirements.
Programmatically exclude products
↑ Back to topThis example excludes products with a skip_google_feed custom field set to yes. The product filter applies to a simple product or the parent of a variation. To apply the same rule to individual variations, register the callback with woocommerce_gpf_exclude_variation.
add_filter( 'woocommerce_gpf_exclude_product', function ( $excluded, $id, $format ) {
return $excluded || (
'google' === $format && 'yes' === get_post_meta( $id, 'skip_google_feed', true )
);
}, 11, 3 );
Change the image size used in the feed
↑ Back to topThe default is full. This example selects the registered WordPress large image size. Before using another size, check the actual image dimensions and Google’s image requirements.
add_filter( 'woocommerce_gpf_image_style', function () {
return 'large';
} );
Omit additional product image links
↑ Back to topUse this filter to omit additional_image_link entries from the Google product feed while retaining the selected primary image. A separately configured lifestyle image can still be included.
add_filter( 'woocommerce_gpf_google_additional_images', '__return_false' );
Choose which images are sent
↑ Back to topThe extension looks for a variation image, the parent product image, gallery images, and images attached to the product. It uses the first available image unless you choose a different primary image.
On the product edit screen, open Product Feed Information and select Manage images. Choose which images to include. The star identifies the primary image. Changes save automatically. Open the generated feed to verify the image_link and any additional_image_link entries.
Register a custom field for prepopulation
↑ Back to topThis example makes _my_custom_field available for mapping. Replace it with the field key in your store. In WooCommerce → Settings → Product Feeds, select refresh the field list, then choose My custom field for the relevant feed attribute.
add_filter( 'woocommerce_gpf_custom_field_list', function ( $fields ) {
$fields['meta:_my_custom_field'] = 'My custom field';
return $fields;
} );
Remove shipping weight from the feed
↑ Back to topThis filter clears both product weight and a mapped shipping weight. Before using it, check whether your Merchant Center shipping setup requires this attribute.
add_filter( 'woocommerce_gpf_feed_item_google', function ( $item ) {
unset( $item->additional_elements['shipping_weight'] );
$item->shipping_weight = null;
return $item;
} );
Remove shipping dimensions from the feed
↑ Back to topThis filter removes all three shipping dimensions. Verify that your Merchant Center shipping rules still calculate the expected rates before submitting the changed feed.
add_filter( 'woocommerce_gpf_elements_google', function ( $elements ) {
unset( $elements['shipping_length'], $elements['shipping_width'], $elements['shipping_height'] );
return $elements;
}, 11 );
Hide attribute labels in variation titles
↑ Back to topThis filter preserves attribute values while omitting their labels. For example, Widget (Size: Small, Color: Light) becomes Widget (Small, Light).
add_filter( 'woocommerce_gpf_include_attribute_labels_in_title', '__return_false' );
Modify the title used in the feed
↑ Back to topSet a default in WooCommerce → Settings → Product Feeds, or override it on the product edit screen under Product Feed Information → Common fields. This example reads a google_feed_title custom field. Use a distinct title for each variation. The filter also receives the parent product ID as its third argument.
add_filter( 'woocommerce_gpf_title', function ( $title, $product_id ) {
$value = get_post_meta( $product_id, 'google_feed_title', true );
$text = is_string( $value ) ? trim( wp_strip_all_tags( $value ) ) : '';
return '' !== $text ? $text : $title;
}, 10, 2 );
Keep the IDs generated in the feed stable
↑ Back to topThe extension generates a product ID for each item. Keep IDs stable after submitting a feed because changing them can disrupt product history in Merchant Center and Google Ads. If a new integration requires a different identifier, the Google feed item exposes guid and item_group_id through woocommerce_gpf_feed_item_google. Verify unique, stable IDs across products and retain consistent grouping across variations and matching data sources before submitting. Google ID requirements.
Modify the product URL sent in the feed
↑ Back to topThis example adds a query parameter to the product URL while preserving the product page and other query parameters. Open the resulting URL and check that it meets Google’s landing-page link requirements.
add_filter( 'woocommerce_gpf_feed_item_google', function ( $item ) {
$item->purchase_link = add_query_arg( 'utm_source', 'google', $item->purchase_link );
return $item;
} );
Questions and feedback
↑ Back to topIf an export still shows the old value, regenerate the test feed and verify that your filter runs for the intended feed type. Remove the new filter to return to the default behavior.
Questions and support
↑ Back to topSomething missing from this documentation? Still have questions and need assistance?
- If you have a question about an extension or theme you’d like to purchase, visit our contact page and use the AI Assistant or contact options.
- If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.