Home › Forums › WoodMart support forum › Warning: array_key_exists() › Reply To: Warning: array_key_exists()
November 29, 2021 at 8:25 am
#335360
Artem Temos
Keymaster
Hi,
Try to add the following PHP code snippet to the child theme functions.php file to fix this
function woodmart_add_brands_to_structured_data( $markup ) {
global $post;
if ( isset( $markup['brand'] ) ) {
return $markup;
}
$brands = get_the_terms( $post->ID, woodmart_get_opt( 'brands_attribute' ) );
if ( ! empty( $brands ) && is_array( $brands ) ) {
// Can only return one brand, so pick the first.
$markup['brand'] = array(
'@type' => 'Brand',
'name' => $brands[0]->name,
);
}
return $markup;
}
add_filter( 'woocommerce_structured_data_product', 'woodmart_add_brands_to_structured_data', 20 );
Kind Regards