Warning: array_key_exists()
-
Hi
I was told to explain our problem here.
We are getting the following error on a singel product page:
Warning: array_key_exists() expects parameter 2 to be array, bool given in /home/onsalasol/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/functions.php on line 17
You can see here: https://onsalasol.se/product/sugar-suede-lush-ultra-nourishing-moisturizer-devoted-creations/
As I am working for the owner of the website I cant create a login.
Please check this and get back to med as soon as you ca…Please
Attachments:
You must be
logged in to view attached files.
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
Thank you!!
That worked 🙂
Great support, do we need to erase this with later updates?
Yes, it will be included in our next theme update so you can erase it then.