Skip to content

Instantly share code, notes, and snippets.

@StefsterNYC
Created June 30, 2026 21:45
Show Gist options
  • Select an option

  • Save StefsterNYC/c64eae2a471b913bae5fb8a239035ff6 to your computer and use it in GitHub Desktop.

Select an option

Save StefsterNYC/c64eae2a471b913bae5fb8a239035ff6 to your computer and use it in GitHub Desktop.
Add GTIN to WooCommerce
<?php
/**
* @snippet Adds a column for the new GTIN input field on Products so when you export the column shows
* @author Serafin Tech
* @compatible WooCommerce 9+
* @website https://serafintech.io
*/
// Add the GTIN/UPC/EAN/ISBN to the export column names
add_filter('woocommerce_product_export_column_names', 'add_custom_gtin_export_column');
function add_custom_gtin_export_column($columns) {
// Add a new column for GTIN/UPC/EAN/ISBN
$columns['global_unique_id'] = 'GTIN/UPC/EAN/ISBN';
return $columns;
}
// Add the GTIN/UPC/EAN/ISBN data to the export rows
add_filter('woocommerce_product_export_product_row', 'add_custom_gtin_export_row', 10, 3);
function add_custom_gtin_export_row($row, $product, $product_id) {
// Get the GTIN/UPC/EAN/ISBN value from the product meta
$gtin_value = get_post_meta($product_id, '_global_unique_id', true);
// Add the value to the row in the 'global_unique_id' column
$row['global_unique_id'] = !empty($gtin_value) ? $gtin_value : ''; // Fallback for missing values
return $row;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment