Google Product Feed – Customizations

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 description ↑ Back to top

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:

https://gist.github.com/leewillis77/64e9291d601e76d35d7f1a24f6f2d523

For WooCommerce 2.6.x or lower, use this snippet:

https://gist.github.com/leewillis77/1f55fd91f7da2a3c190bca255d2642c7

Creating a bespoke description ↑ Back to top

If you need to completely customise the description used in the feed you can use the snippet below:

https://gist.github.com/leewillis77/42589c00917bca8cf685e320bf2f75d7

Populate the feed with custom values ↑ Back to top

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:

https://gist.github.com/leewillis77/19179188828d04624ce5d3fbdbae6c23

Exclude categories from the feed ↑ Back to top

This snippet shows how to exclude products in certain categories from the feed:

https://gist.github.com/leewillis77/65fc4babd0f7a3776966e2324965bf6a

Change the image size used in the feed ↑ Back to top

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.

https://gist.github.com/leewillis77/b61b0a1b7649d36c05ebe94e5260042b

Disable additional images from being included ↑ Back to top

The following snippet will cause only the single, main product image to be sent in the feed.

https://gist.github.com/leewillis77/0c07a1c3874e9b7c9e3ada337e91d474

Choose which images are sent ↑ Back to top

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.

Screenshot of image management in Google Product Feed extension

Clicking on “Manage images” allows you to modify these settings. Changes you make will be automatically saved.

Image management in Google Product Feed extension

Register custom field for pre-population ↑ Back to top

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.

https://gist.github.com/leewillis77/27fe2a18ca76e88cca150a1912cbbaac

Remove shipping weight from feed ↑ Back to top

If you want to remove the shipping weight from the feed you can do so with the following snippet:

https://gist.github.com/leewillis77/8efe43edea7113080862f346073e3c1a

Remove shipping dimensions from feed ↑ Back to top

The following snippet can be used to remove all shipping dimensions (length, width and height) from products in the feed:

https://gist.github.com/leewillis77/0371a8307535ada0a321147e7617c432

Hide attribute labels on variable product titles ↑ Back to top

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 behaviour use the following snippet:

https://gist.github.com/leewillis77/afd6fdf15b1b0a1e720372197cee5a56

Modifying the title used in the feed ↑ Back to top

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 programatically, then the following code snippet shows how you can use a filter to do so.

https://gist.github.com/leewillis77/44cb3317890470d96a316915f6476aa9

Modifying the ID generated in the feed ↑ Back to top

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:

https://gist.github.com/leewillis77/96b01e82d9e668300d10d257838d20ec

Modifying the product URL sent in the feed ↑ Back to top

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.

https://gist.github.com/leewillis77/bf7078c28e8d0c6069f100b4e61be539

Questions & Feedback ↑ Back to top

Have a question before you buy? Please fill out this pre-sales form.

Already purchased and need some assistance? Open a support ticket via the Help Desk.

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top