Created
December 15, 2025 10:10
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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