-
There’s a new WooCommerce Update that includes the product GTIN. Is there any possible way to automatically transfer the GTIN from RankMath to the WooCommerce GTIN field?
-
Hello,
We apologize for the issue you are facing. Unfortunately, the context does not provide information on automatically transferring the GTIN from Rank Math to the WooCommerce GTIN field.
We recommend replying to this ticket, and a human agent from the Rank Math Support team will be able to assist you further with your inquiry.
Thank you for raising this concern!
Hello,
Thank you for contacting Rank Math support.
The GTIN feature of our plugin is only available in the PRO version. You have created this ticket using a free account. Please confirm the email address of your PRO account so we can verify your purchase and assist you further.
Looking forward to helping you.
This is the email used:
d**********@n**********Hello,
You can use the following filter to copy Rank Math GTIN data to WooCommerce’s GTIN field:
function update_gtin() { $posts = get_posts(array( 'posts_per_page' => -1, 'post_type' => 'product' // Replace post with the name of your post type )); foreach($posts as $p){ $rank_math_gtin = get_post_meta( $p->ID, '_rank_math_gtin_code', true ); update_post_meta($p->ID, '_global_unique_id', $rank_math_gtin); } } add_action( 'init', 'update_gtin' );
If you have a lot of products, then use the following filter:
function update_gtin() { $posts = get_posts(array( 'posts_per_page' => 1000, 'offset' => 1000, 'post_type' => 'product' // Replace post with the name of your post type )); foreach($posts as $p){ $rank_math_gtin = get_post_meta( $p->ID, '_rank_math_gtin_code', true ); update_post_meta($p->ID,'_global_unique_id',$rank_math_gtin); } } add_action( 'init', 'update_gtin' );
This code will add the GTIN for 1000 products at once. Please make sure to increase the offset value by 1000 each time you run the code.
Once the GTIN is updated for each product, remove the code from your site.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
I added the code to my theme’s function.php. Should I wait for a few minutes for this to take effect?
I have checked and the GTIN is still not added. I also check the product variants, it is still not taking effect.Hello,
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
If the issue persists, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping you.
Thanks.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
I have done both, it is still not working. I have updated the sensitive data with the FTP and wp login.
Also this info would help.
The products are variables. So there are GTIN on each product variables.
Hello,
Sorry for the delay in getting back to you.
To apply the same behavior to the variations you should be able to add the variation post type into the function by editing the line:
'post_type' => 'product'
To the following:
'post_type' => ['product', 'product_variation']
This will apply the settings for both but please be sure to follow the recommendations we shared above if you have a lot of products.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.
The ticket ‘RankMath GTIN to WooCommerce’ is closed to new replies.