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 topInstall 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 topAdd 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- In your WordPress dashboard, go to Marketing > Google for WooCommerce > Attributes and select Create attribute rule.
- Select GTIN as the target, then select Use value from existing product field.
- 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 topDo 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.