Render GTIN in Product structured data (#50087)
* Add GTIN in structured data * Changelog * Add changefile(s) from automation for the following project(s): woocommerce * Delete plugins/woocommerce/changelog/50087-tweak-add-gtin-ld-json * Add changefile(s) from automation for the following project(s): woocommerce * Lint * Delete plugins/woocommerce/changelog/50087-tweak-add-gtin-ld-json --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
c9aa65a22f
commit
a883856171
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: tweak
|
||||
|
||||
Add GTIN in structured data
|
|
@ -214,6 +214,12 @@ class WC_Structured_Data {
|
|||
$markup['sku'] = $product->get_id();
|
||||
}
|
||||
|
||||
// Add GTIN only if it's a valid number.
|
||||
$gtin = $product->get_global_unique_id();
|
||||
if ( $gtin && is_numeric( $gtin ) ) {
|
||||
$markup['gtin'] = $gtin;
|
||||
}
|
||||
|
||||
if ( '' !== $product->get_price() ) {
|
||||
// Assume prices will be valid until the end of next year, unless on sale and there is an end date.
|
||||
$price_valid_until = gmdate( 'Y-12-31', time() + YEAR_IN_SECONDS );
|
||||
|
|
Loading…
Reference in New Issue