Customisations
Note: This is a Developer level section. If you are unfamiliar with code and resolving potential conflicts, select a WooExpert or Codable for assistance. We are unable to provide support for customizations under our Support Policy.
Use the short product description instead of the description
If you’re using version 7.8.0 or higher, then the plugin provides options for choosing how to create the description in the feed. The correct option to choose will depend on how you’ve populated your product data.
The full list of available options is shown in the screenshot below:
The default option for new setups is “Main product description (full preferred) plus variation description“. For stores coming from older versions of the extension, they will be set to “Variation description only, fallback to main description (full preferred)” which matches the previous behaviour of the plugin.
If you’re on an older version of the plugin then you can use one of the snippets below to customise the description, although we’d recommend upgrading to version 7.8.0 or higher and using the built-in options as above.
If you’re using WooCommerce 3.0 or higher, use this snippet:
| <?php |
| |
| function lw_woocommerce_gpf_description_type( $type ) { |
| return 'short'; |
| } |
| add_filter( 'woocommerce_gpf_description_type', 'lw_woocommerce_gpf_description_type' ); |
For WooCommerce 2.6.x or lower, use this snippet:
| <?php |
| |
| function lw_woocommerce_gpf_description( $description, $product_id, $variation_id = null ) { |
| global $post; |
| if ( ! is_null( $variation_id ) ) { |
| $ID = $variation_id; |
| } else { |
| $ID = $product_id; |
| } |
| $save_post = $post; |
| $post = get_post( $ID ); |
| if ( ! empty( $post->post_parent ) ) { |
| $post = get_post( $post->post_parent ); |
| } |
| setup_postdata( $post ); |
| $excerpt = get_the_excerpt(); |
| $post = $save_post; |
| return $excerpt; |
| } |
| add_filter( 'woocommerce_gpf_description', 'lw_woocommerce_gpf_description', 10, 3 ); |
Creating a bespoke description
If you need to completely customise the description used in the feed you can use the snippet below:
| <?php |
| |
| function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) { |
| // Modify $feed_item->description here. |
| return $feed_item; |
| } |
| add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 10, 2 ); |
hosted with by GitHub
Populate the feed with custom values
You can add or override any element value with one of your own using the filters in the plugin. Here’s an example of populating the “brand” element from a custom field called supplier_brand_name:
| <?php |
| |
| function lw_woocommerce_gpf_add_brand( $elements, $product_id, $variation_id = null ) { |
| if ( ! is_null( $variation_id ) ) { |
| $id = $variation_id; |
| } else { |
| $id = $product_id; |
| } |
| $product = wc_get_product( $id ); |
| $brand = $product->get_meta( 'supplier_brand_name' ); |
| if ( ! empty( $brand ) ) { |
| $elements['brand'] = array( $brand ); |
| } |
| return $elements; |
| } |
| add_filter( 'woocommerce_gpf_elements', 'lw_woocommerce_gpf_add_brand', 11, 3 ); |
Programatically excluding products
If you want to programmatically exclude products from the feed based on your own logic, the following snippet shows how to do so.
| <?php |
| |
| function lw_gpf_exclude_product( $excluded, $product_id, $feed_format ) { |
| // return TRUE to exclude this product |
| // return FALSE to include this product |
| |
| // return $excluded to keep the standard behaviour for this product. |
| return $excluded; |
| } |
| |
| add_filter( 'woocommerce_gpf_exclude_product', 'lw_gpf_exclude_product', 11, 3 ); |
Change the image size used in the feed
By default, the feed uses the “full” image style. If you want to send an alternative image size, you can adapt this snippet to change the image size used to any of the registered image sizes. This example sets it to the “shop_catalog” image size.
| <?php |
| |
| function filter_woocommerce_gpf_image_style( $style ) { |
| return 'shop_catalog'; |
| } |
| add_filter( 'woocommerce_gpf_image_style', 'filter_woocommerce_gpf_image_style' ); |
Disable additional images from being included
The following snippet will cause only the single, main product image to be sent in the feed.
| <?php |
| |
| add_filter( 'woocommerce_gpf_include_product_gallery_images', '__return_false' ); |
| add_filter( 'woocommerce_gpf_include_attached_images', '__return_false' ); |
Choose which images are sent
The extension automatically includes images in the feed, including:
- Variation image (on variable products)
- The “Product Image” set on the main product
- Any “Product Gallery” images added to the product
- Any other media files attached to the product in WordPress
The extension will automatically select the first image found from the above as the primary image to use in the feed. If you want to choose exactly which images are/aren’t included and which image is used as the primary image, then you can do so on the edit product page under Product Feed Information. By default, the plugin will show thumbnails of all images that have been found for that product, and indicate whether they are currently included, or excluded, and will indicate any primary image selected by marking with a star.
Clicking on “Manage images” allows you to modify these settings. Changes you make will be automatically saved.
Register custom field for pre-population
The pre-population options in the extension do not include “hidden” meta, or custom fields by default. If you want to make a custom field available as a pre-population option then you can use the following snippet, simply replace “_my_custom_field” with the field name of your custom field.
Note: Once this snippet is in place, you will need to click on the “Refresh the field list” link on the settings page before it will be available to select as an option to select.
| <?php |
| |
| function lw_woocommerce_gpf_custom_field_list( $list ) { |
| // Register the _my_custom_field meta field as a pre-population option. |
| $list['meta:_my_custom_field'] = 'My custom field'; |
| return $list; |
| } |
| add_filter( 'woocommerce_gpf_custom_field_list', 'lw_woocommerce_gpf_custom_field_list' ); |
Remove shipping weight from feed
If you want to remove the shipping weight from the feed you can do so with the following snippet:
| <?php |
| |
| function lw_exclude_shipping_weight( $feed_item ) { |
| $feed_item->shipping_weight = null; |
| return $feed_item; |
| } |
| add_filter( 'woocommerce_gpf_feed_item_google', 'lw_exclude_shipping_weight' ); |
Remove shipping dimensions from feed
The following snippet can be used to remove all shipping dimensions (length, width and height) from products in the feed:
| <?php |
| |
| function lw_gpf_remove_shipping_attrs($elements, $product_id) { |
| unset($elements['shipping_width']); |
| unset($elements['shipping_length']); |
| unset($elements['shipping_height']); |
| return $elements; |
| } |
| add_filter( 'woocommerce_gpf_elements_google', 'lw_gpf_remove_shipping_attrs', 11, 2 ); |
Hide attribute labels on variable product titles
When generating feed items for variable products, the extension generates unique titles for each variation by including attribute information in the feed title as per Google’s requirements. For example, a “Widget” available in 2 different colors and sizes might have its four items listed as:
- Widget (Size: Small, Color: Light)
- Widget (Size: Small, Color: Dark)
- Widget (Size: Large, Color: Light)
- Widget (Size: Large, Color: Dark)
If you have many attributes or complex attribute names on your variable products then this may generate overly long item titles. The extension will allow you to drop the attribute name (“Size” and “Color” in the previous example). This would generate titles like this:
- Widget (Small, Light)
- Widget (Small, Dark)
- Widget (Large, Light)
- Widget (Large, Dark)
To enable this behavior use the following snippet:
| <?php |
| |
| add_filter( 'woocommerce_gpf_include_attribute_labels_in_title', '__return_false' ); |
Modifying the title used in the feed
The plugin settings (WooCommerce » Settings » Product Feeds) allow you to choose what is used for the title in the feed. You can choose from the standard product title from WooCommerce, or any of the other supported fields.
As with other feed elements, you can also override the calculated title by supplying a title explicitly in the “Product Feed Information” section of the edit product page:
If you want to modify the title used in the feed programmatically, then the following code snippet shows how you can use a filter to do so.
Modifying the ID generated in the feed
The extension automatically generates a unique ID for every product in the feed that meets Google’s requirements for IDs. If you need to change this then you can do so with the following snippet, although we do not recommend this.
However: Changing the ID is not recommended as the value you choose for it must meet strict requirements including that it should be unique, and non-changing over time. As such values such as the SKU, or MPN aren’t recommended.
Note: Changing the ID format for an existing feed will result in duplicate products being created, with the new version requiring approval and validation before they can be used for product ads.
If you do still wish to change the ID, then the following snippet shows the filter you can use:
| <?php |
| function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) { |
| // Modify $feed_item->guid here. |
| // Note, you may also need to update $feed_item->item_group_id if you have variable products. |
| return $feed_item; |
| } |
| add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 11, 2 ); |
Modifying the product URL sent in the feed
Sometimes you may want to customise the product URL sent in the feed for products. You can do this using the filter below, putting whatever logic in place to modify $feed_item->purchase_link to meet your needs.
| <?php |
| function lw_woocommerce_gpf_feed_item_google( $feed_item, $product ) { |
| // Modify $feed_item->purchase_link here. |
| return $feed_item; |
| } |
| add_filter( 'woocommerce_gpf_feed_item_google', 'lw_woocommerce_gpf_feed_item_google', 10, 2 ); |
Google Product Review / Product rating feeds
Version 7.7.0 of the extension adds support for Google’s Product Review Feeds.
This allows you to send a feed to Google with details of all of your customer reviews, which can then enhance your product listing ads.
Before you start
Before starting, you will need to apply to Google’s product review feed program.
Set up & configuration
You can create a product review feed in your WooCommerce settings, under WooCommerce > Product Feeds.
Click on “Add New”, and set the type to “Google merchant center product review feed”, e.g.
That’s the only configuration required on the WooCommerce side – just take a note of the feed URL shown after you save, as you’ll need it when setting up your review feed in Google Merchant Center.
Adding your feed to Google Merchant Centre
Once you’ve been accepted onto the Google Product Review program, and have enabled your feed, you’ll need to set it up inside Google Merchant Center.
- Log in to your Merchant Center account
- Go to: Product Reviews > Feeds
- Click the Add button
Enter the requested Basic information, and press Continue
Enter the feed name woocommerce-review.xml and make sure that Scheduled Fetch is selected before clicking Continue
Enter the filename, choose a fetch time, and enter the feed URL you noted earlier
Once that is completed, then Google will fetch and validate your feed and contact you if there are any issues.
Troubleshooting
If there are any issues with the feed file you uploaded, you can click on the feed name to get further details. A list of errors and warnings is provided, with a description of what is required to resolve the issue and examples of some items affected.
Generally resolving these will be a case of enabling a feed field, and providing data for it, or resolving data quality issues with the data being output. For information on setting up the values that go into the feed read the support article on Setting Product Data.
If you need to raise a support ticket about data issues from this page, then please be sure to include the full, exact error message, and at least one specific item ID that exhibits the error. The feed page includes a Download full report button which can be used to download a list of all errors/warnings.
My feed is missing tax
To account for tax on your products, configure tax rules in your Google Merchant Center account. You can find options in the Sales Tax menu item in the Tools menu in your Google Merchant Center Account
Shipping rules need to be configured in your Google Merchant Center account. Shipping configuration is accessed from the “Delivery & returns” link in the Tools menu of your Google Merchant Centre account.
The feed includes shipping weights for products if you need to set up weight-based pricing. It’s not practical to provide shipping information in the feed itself. The feed can also be configured to send delivery_label information (which can be mapped to shipping classes in WooCommerce) if that helps you set up more accurate shipping information.
Insufficient product identifiers: Missing two out of three attributes [GTIN, Brand, MPN]
Google requires you to submit product identifiers for certain classes of products. The plugin supports all of the elements you need, however, which you use will depend on your store. You can enable any of the required fields (GTIN / Brand / MPN) on the plugin settings page (WooCommerce >Settings >Product Feeds) as well as setting defaults, or pre-population rules to pull in data from other fields (e.g. SKU). For more information on providing product data, see the article on Setting Product Data.
Google says my feed is missing “xxxxxx”
Verify that you selected the fields needed for your region and market sector on the Settings page found at WooCommerce >Settings >Product Feeds.
If you’re unsure what information to provide, read Google’s guidance at Product Feeds Specification. Once you know which fields are missing, read the support article on Setting Product Data.
Generating the product feed means that WordPress must load all product data in a single request, and it often takes more resources than an average page request. The feed generator tries to be as efficient as possible but depending on the size and complexity of your store, and your chosen hosting environment, it may hit limits, either time limits, or memory limits.
If you do encounter issues, there are a number of things you can do:
Speak with your web host and see if the limits can be increased
Enable feed item caching
Ask Google to fetch per-category feeds for individual, or groups of categories rather than the full store
Submit partial/limited feeds to Google
If you are hosted at WPEngine, they don’t allow Google to access URLs with query arguments. Instead, use a permalink-style URL.
My sale prices aren’t showing
Sale prices are included in the feed automatically and should feed through to Google Merchant Centre automatically.
However, Google Merchant Centre shows the “standard price” in most places, which can be confusing. However, if you view the details of an individual product in your Google Merchant Centre account you should be able to confirm that the sale price is present. Navigate to Products » All Products and click on a specific product. On the product, detail screen scroll down to the “Final Attributes” section, and you should see your sale price listed:
While the Google Product Feed extension tries its best to play nicely with other extensions there are some areas where specific integration can yield better results.
The extension has specific support for the following WooCommerce extensions:
- Brands
- Composite Products
- Cost of Goods
- Currency Switcher for WooCommerce
- Min/Max Quantities
- Mix & Match Products
- MSRP Pricing
- Multi-Currency
- Price by Country
- Product Bundles
- Product CSV Import Suite
- Product Vendors
If you have a query about compatibility with a specific extension, reach out with a support request.
Product bundles integration
Bundle products created with the WooCommerce Product Bundles extension will be included in the feed as long as a default configuration for the bundle exists, and is valid for submission.
Composite products integration
Composite products created with the WooCommerce Composite Products extension will be included in the feed as long as a default configuration exists, and is valid for submission.
Brands integration
If you’ve assigned brands to your products using the WooCommerce Brands extension, then those brands can automatically be pulled through into your Google Product Feed.
Cost of goods integration
If you’ve used the WooCommerce Cost of Goods extension to assign costs to your products then you can automatically feed those costs through to Google Merchant Centre, allowing you to gain insights about metrics, such as your gross margin and the amount of revenue generated by your Shopping ads.
Multi-currency integration
If you have the WooCommerce Multi-Currency extension then you can submit feeds to Google in any of the currencies that you have enabled in the multi-currency extension.
Choose the target country by adding a currency parameter to the feed URL with the required currency code, e.g.
Min/Max Quantities
If you have minimum purchase quantities set on your products using the WooCommerce Min/Max quantities extension, then the feed will automatically detect this, and ensure that the price sent to Google reflects the price to purchase the minimum quantity. So that Google properly understands your pricing, the plugin will also automatically send unit_pricing_measure and unit_pricing_base_measure information. For example, for a product priced at $1, and a minimum purchase quantity of 5, the feed would send:
<g:price>5.00 USD</g:price>
<g:unit_pricing_measure>5 ct</g:unit_pricing_measure>
<g:unit_pricing_base_measure>1 ct</g:unit_pricing_base_measure>
Mix & Match Products
Mix & match products will be included in your feed automatically. Products, where the price is set on the bundle, will be priced according to the set price. Products, where the price is set based on the selected items, will be included in the feed based on the minimum available price of the product (the “from” price).
Price By Country
If you have the Price By Country extension then you can submit feeds to Google in any of the countries that you have enabled pricing for in the price by country extension. Choose the target country by adding a price country parameter to the feed URL with the required country code, e.g.
Product CSV Import Suite
There’s full support for WooCommerce Product CSV Import Suite allowing you to import data into any of the product feed data fields. The plugin also supports the import/export tool available in WooCommerce core version 3.1 or higher.
Product Vendors
If you are running the WooCommerce Product Vendors extension the Product Feed extension will automatically include any per-product shipping information that you add to the Google Product Feed.
Currency Switcher for WooCommerce
If you are running the Currency Switcher for WooCommerce extension, then you can generate currency-specific feeds which will include pricing in the specified currency, as well as ensuring that Google validates against product pages in the correct currency.
Choose the target country by adding a currency parameter to the feed URL with the required currency code, e.g.
MSRP Pricing
If you’re running the MSRP Pricing extension, then you can use the MSRP price field to populate any of the pre-populatable elements in the product feed by choosing the “MSRP from MSRP Pricing extension” option, e.g.
Unsupported extensions
Some extensions are known not to be supported, specifically:
WooCommerce Subscriptions: Google does not allow the listing of recurring payment products in Google Merchant Centre, so there is no support for WooCommerce Subscriptions at this time.
WooCommerce Bookings: Google does not allow the listing of event tickets, or services in Google Merchant Centre, so Google Product Feed is not currently compatible with WooCommerce Bookings as most use-cases would not be allowable. If you feel that your site would benefit from this, vote to add it to our Ideas Board: http://ideas.woocommerce.com Doing this lets our developers know what solutions customers need, and then prioritise by demand.
FAQ
How do I send images to Google?
Links to your product images are automatically listed in the feed sent to Google. Nothing more is required.
Does Google Product Feed support product variations?
Yes, product variations are supported.
If you enable variation support, then each variation is sent as a specific item in your feed. Variations use values from attributes where they are set, and you can provide feed-specific data when editing a variation.
Does this plugin allow for valid Google Product Listing Adverts (PLA) to be created?
Yes. It produces a feed to load the store’s products into Google Merchant Center so PLAs can be set up. It provides data entry for all required data, which can be set at store level, category level, or individual product where required; and supports Google’s current feed specification.