Hi there, I am trying to send Google Merchant an ACF field – ‘isbn’ – and map it as the ‘GTIN’ attribute through the ‘Google Listings and Ads’ plugin.
The reason I want this functionality is because my client updates their ISBN on their products with an ACF field in order for it to also get displayed on the front-end. I need to keep it simple for them so they aren’t updating the same value in multiple places.
So therefore need a way for Google Listings and Ads to understand the ACF field and map it to GTIN.
I found this article here which suggests it is possible.
That article tells me to use the following code:
add_filter(
'woocommerce_gla_attribute_mapping_sources_custom_attributes',
function( $values ) {
return array_merge( $values, ['isbn']);
}
);
But I assume that is just fetching a made up field – ‘isbn’ rather than my specific ACF Field – ‘isbn’ which has a value on each product.
I need it to specifically be the ACF field – ‘isbn’ – so that it transmits this data to Google Merchant.
Basically something like this:
add_filter(
'woocommerce_gla_attribute_mapping_sources_custom_attributes',
function( $values ) {
$variable = get_field('isbn');
return array_merge( $values, [$variable]);
}
);
Perhaps I need to push the value to this array somehow? I’m not much into php beyond the basics sorry.
Anyone have any thoughts or experience with this?
It would be much appreciated, thanks.