Hi Holger,
The code you are using should add your GTIN as your GTIN13 data.
Can you please share the URL where you are seeing this issue so that we can help?
Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello Todd,
thanks for taking your time to look at the problem. Any idea, what could be the problem?
HI Holger,
Thanks for getting back to us.
I can suggest that you identify the plugin that is adding the extra fields on the page which will then make it easier to get the MPN or GTIN value from the current product using the plugin’s native API functions.
I hope this info helps. Thank you.
Ah, it is not Woocommerce itself… ok, great.
Thanks for this tip.
It is the germanized plug-in.
And I got this from their help:
add_action( 'woocommerce_product_additional_information', 'my_child_add_ean', 10 );
function my_child_add_ean( $product ) {
echo '<p>GTIN: ' . WC_germanized()->trusted_shops->get_product_gtin( $product ) . '</p>';
echo '<p>MPN: ' . WC_germanized()->trusted_shops->get_product_mpn( $product ) . '</p>';
}
Can I just put that under the former in the function.php under or above what I got from you?
Hello,
You can put it below the code we provided.
Let us know if you need further assistance from us.
Thank you.
Hello Todd,
thanks for reaching out again.
I am sorry, but this code from germanized is not helping anything. That was made to print the GTIN on a individual product page.
Here is their answer from venidero, the maker of germanization, I gave them your code and they had this question with it:
The question is, what exactly is $entity? The problem is that the actual product object or ID is not passed on, so that the product cannot be accessed from there to output additional data. Can you please inquire at RankMath Support about how to get the proper product within the filter so that data can be read out? Unfortunately, this cannot work.
Hi Holger,
Thank you for the reply.
$entity is an array containing the snippet data for the schema that you are trying to modify.
Could you please try to get the value from the global $product object like so:
/**
* Filter to modify schema data.
* @brand for products
* @param array $entity Snippet Data :
* @return array
*/
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
global $product;
$entity['brand'] = 'yourbrandhere';
$entity['offers']['priceValidUntil'] = '2020-12-31';
$entity['gtin'] = WC_germanized()->trusted_shops->get_product_gtin( $product );
return $entity;
});
Let me know how this goes. Thank you.
Hello Michael,
It broke my product pages, not available. So not too good.
With the two // is all good again. 🙂 Thanks for the idea.
Maybe you can get me the right code for the second php snippet?
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
global $product;
$entity['brand'] = 'com';
$entity['offers']['priceValidUntil'] = '2020-12-31';
$entity['gtin'] = WC_germanized()->trusted_shops->get_product_gtin( $product );
return $entity;
});
Like this also not working.
-
This reply was modified 4 years, 10 months ago by Holger Gaier.
-
This reply was modified 4 years, 10 months ago by Holger Gaier.
-
This reply was modified 4 years, 10 months ago by Holger Gaier. Reason: wrong code, changed it, also not working
Hello,
Thanks for getting back to us.
We might need to take a closer look at the settings and run some tests on the integration with Germanized WC. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
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.
Right now I have the stupid Germanized/Trusted-Shop Plugin. Additional I put on the code snippet I showed you up there. This is working fine.
Can you try to see from this what is needed to get me the right code to put GTIN and MPN into RankMathe product Schema array? As I will have no problem using the code snippet instead of Germanized/TrustedShop for GTIN and MPN on all my products.
Btw. I tried the plugin you recommend before, but that was also not working.
-
This reply was modified 4 years, 10 months ago by Holger Gaier. Reason: spelling
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.