Expose a custom field for Google for WooCommerce attribute mapping

Make an existing product custom field available as a source for Google for WooCommerce attribute-mapping rules. This example exposes an ISBN field named isbn.

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 customizations. We are unable to provide support for customizations under our Support Policy.

Before you start

↑ Back to top

Install and configure Google for WooCommerce, and confirm that the products you want to map already have an isbn custom field. Test custom code on a staging copy before using it on a live store.

Register the custom field

↑ Back to top

Add the following snippet to a custom plugin or a code-snippet management plugin. Replace isbn with your custom field key if needed.

add_filter(
	'woocommerce_gla_attribute_mapping_sources_custom_attributes',
	function ( $attributes ) {
		$attributes[] = 'isbn';
		return $attributes;
	}
);

Create and check the rule

↑ Back to top
  1. In your WordPress dashboard, go to Marketing > Google for WooCommerce > Attributes and select Create attribute rule.
  2. Select GTIN as the target, then select Use value from existing product field.
  3. Under Custom Attributes, select isbn, choose the applicable categories, and save the rule.

Confirm that the rule appears in the attribute-mapping list and that the relevant products have the expected custom field value. If the source is missing, check that the snippet is active and the key matches the product custom field.

A product’s built-in WooCommerce GTIN, UPC, EAN, or ISBN value takes precedence when it is populated. Review that field if the synced GTIN differs from the custom field.

Questions and support

↑ Back to top

Do you still have questions and need assistance? 

  • Get in touch with a Happiness Engineer via our Help Desk. We provide support for extensions developed by and/or sold on WooCommerce.com, and Jetpack/WordPress.com customers.
  • If you are not a customer, we recommend finding help in the WooCommerce support forum or hiring a Woo Agency Partner. These are trusted agencies with a proven track record of building highly customized, scalable online stores. Learn more about Woo Agency Partners.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.