Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created December 15, 2025 10:10
Show Gist options
  • Select an option

  • Save webtoffee-git/cb1c0bf6a6a5cdbe73fb36443b3c0b3c to your computer and use it in GitHub Desktop.

Select an option

Save webtoffee-git/cb1c0bf6a6a5cdbe73fb36443b3c0b3c to your computer and use it in GitHub Desktop.
Code snippet to automatically add prefix to product IDs - By WebToffee( Product feed for WooCommerce Basic)
<?php // Do not copy this line of code
/**
* Prefix product ID in feed output.
*
* @param string|int $product_id Product ID being processed.
* @param WC_Product $product Product object.
*
* @return string|int Modified product ID.
*/
function wbtfe_product_feed_alter_product_id( $product_id, $product ) {
if ( ! empty( $product_id ) ) {
return 'gla_' . $product_id;
}
return $product_id;
}
add_filter( 'wt_feed_filter_product_id', 'wbtfe_product_feed_alter_product_id', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment