-
Notifications
You must be signed in to change notification settings - Fork 24
Description
User story
(I'm french some this text could contain some french word ;) ) As a merchant using WooCommerce with the official Google for Commerce plugin, I want to be able to programmatically sync my product variation attributes (size, color, age group, etc.) to Google Merchant Center.
This is especially important for stores that manage large catalogs and need to automate product metadata updates.
Currently, when we update the appropriate GLA metadata via custom scripts (e.g., using update_post_meta()), Google Merchant Center does not receive those values, and they are not displayed in the WooCommerce admin panel either.
Is your feature request related to a problem?
Yes. The current implementation of the Google Listings & Ads plugin appears to ignore the wc_gla_attribute* and woocommerce_gla_field* fields when they are created programmatically. These fields:
- are present in the database (wp_postmeta)
- hold correct values (size, color, age group)
- but are not used by the plugin to populate the product feed or display in the admin interface.
This creates a confusing and incomplete synchronization flow for developers and merchants who rely on automation.
How to reproduce the problem
- Create a WooCommerce product with several variations (e.g., sizes and colors).
- Use a script (e.g., via update_post_meta()) to set:
- _wc_gla_attribute_size
- _wc_gla_attribute_color
- _wc_gla_attribute_age_group
- Go to the WooCommerce admin > Product > Variations > Google for WooCommerce section.
- Observe that the values (size, color, age group) are not visible in the admin.
- Check Google Merchant Center: the feed does not include the values either.
Describe the solution you'd like
We would like the plugin to recognize and properly use GLA-related metadata when updated programmatically, without needing to manually re-save the product in the admin UI.
This could be achieved by:
- Properly reading wc_gla* fields if already present
- Or providing a hook/filter that allows third-party developers to register or "force" metadata sync for GLA
- Optionally, providing official documentation on the minimal required fields for GLA sync
Describe alternatives you've considered
- Manually editing every product and variation in the admin interface (not scalable)
- Re-saving every product via code using WooCommerce internal functions (complex and error-prone)
- Trying to simulate admin UI save actions in a custom plugin (fragile and against best practices)
Technical
I created a PHP script and I launched it with a cron every day to ensure the data are copy and Google Merchant Center is all green:
<?php
define('WP_USE_THEMES', false);
require_once('wp-load.php');
function translate_color($color_fr) {
$map = [
'Blanc' => 'White',
'Noir' => 'Black',
'Marine' => 'Navy',
'Gris' => 'Gray',
'Orange' => 'Orange',
'Jaune' => 'Yellow',
'Lavande' => 'Lavender',
'Naturel' => 'Natural',
'Rose' => 'Pink',
'Bleu' => 'Blue',
'Bordeaux' => 'Burgundy',
'Indigo' => 'Indigo'
];
return $map[$color_fr] ?? $color_fr;
}
$args = [
'post_type' => 'product_variation',
'posts_per_page' => -1,
'post_status' => 'publish',
'fields' => 'ids'
];
// test only from multiples variations of 1 product
$variations = [4631, 4638, 4644];
// enable this to do all products
//$variations = get_posts($args);
$count_total = 0;
$count_updated = 0;
foreach ($variations as $variation_id) {
$size = get_post_meta($variation_id, 'attribute_taille', true);
$color = get_post_meta($variation_id, 'attribute_couleur', true);
$color_en = translate_color($color);
if (!$size && !$color) continue;
$age_group = (preg_match('/^\d{1,2}-\d{1,2}/', $size)) ? 'kids' : 'adult';
update_post_meta($variation_id, '_wc_gla_size', $size);
update_post_meta($variation_id, '_wc_gla_color', $color_en);
update_post_meta($variation_id, '_wc_gla_ageGroup', $age_group);
update_post_meta($variation_id, '_wc_gla_condition', 'new');
update_post_meta($variation_id, '_wc_gla_sizeSystem', 'EU');
echo "#$variation_id : size=$size | color=$color_en | age_group=$age_group\n";
$count_updated++;
}
echo "\n Terminé : $count_updated/$count_total variations mises à jour.\n";
?>
Acceptance criteria
- Programmatically created GLA metadata (wc_gla, woocommerce_gla_field) is recognized and included in the Google feed
- These fields are displayed in the admin interface (in the product variation > GLA section)
- Documentation is updated to include the required fields and their expected formats
Unknowns
- Is there any internal validation or cache preventing the programmatic sync?
- Is a manual UI interaction required to trigger a sync?
- Are fields like wc_gla_attribute* officially deprecated?
Out of bounds/rabbit holes
- WooCommerce’s object caching may interfere with immediate update_post_meta() syncs
- Synchronization might be delayed by scheduled actions (Action Scheduler)