Home / Forums / WoodMart support forum / Compatibility with Woocommerce Product Brands Core
Home › Forums › WoodMart support forum › Compatibility with Woocommerce Product Brands Core
Compatibility with Woocommerce Product Brands Core
- This topic has 5 replies, 2 voices, and was last updated 1 day, 22 hours ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
December 3, 2025 at 10:15 am #698905
MikeParticipantHi, i was using the attribute for product brands, but since the Woocommerce integrated product brands to its core, i switched to check how its work. I have found that the woodmart wp bakery brand element its not working with the brand images. If you see the screenshot all images from brands are shown broken, and also the same broken are show on product page if brand assigned to product element its used. This probably it happen because the attribute method use a different class for image than the woocommerce brands?
Attachments:
You must be logged in to view attached files.December 3, 2025 at 11:35 am #698928
MikeParticipantI have temporary fix it with a small override on functions.php wit this code
/** * Fix WooCommerce Brands image compatibility with Woodmart theme * Converts numeric image IDs to array format expected by Woodmart */ add_filter( 'get_term_metadata', 'fix_woodmart_brand_image_format', 10, 4 ); function fix_woodmart_brand_image_format( $value, $object_id, $meta_key, $single ) { // Only process 'image' meta key if ( 'image' !== $meta_key ) { return $value; } // Prevent infinite loop static $is_checking = false; if ( $is_checking ) { return $value; } $is_checking = true; $actual_value = get_term_meta( $object_id, $meta_key, true ); $is_checking = false; // If numeric (attachment ID), convert to array format for Woodmart if ( $actual_value && is_numeric( $actual_value ) ) { if ( $single ) { return array( 'id' => $actual_value ); } else { return array( array( 'id' => $actual_value ) ); } } return $value; }The compatibility issue it comes from those two files:
/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/brands.php
You must change this code:
foreach ( $brands as $brand ) { $image = get_term_meta( $brand->term_id, 'image', true ); $attrs = ''; if ( get_term_meta( $brand->term_id, 'image_id', true ) ) { $data = wp_get_attachment_image_src( get_term_meta( $brand->term_id, 'image_id', true ) ); $attrs = ' width="' . $data['1'] . '" height="' . $data['2'] . '"'; } if ( ! $image ) { $thumbnail_id = get_term_meta( $brand->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = array( 'id' => $thumbnail_id, ); } }With this code:
foreach ( $brands as $brand ) { $image = get_term_meta( $brand->term_id, 'image', true ); $attrs = ''; if ( get_term_meta( $brand->term_id, 'image_id', true ) ) { $data = wp_get_attachment_image_src( get_term_meta( $brand->term_id, 'image_id', true ) ); $attrs = ' width="' . $data['1'] . '" height="' . $data['2'] . '"'; } // Fix: If 'image' meta contains an attachment ID (numeric), convert to array format if ( $image && is_numeric( $image ) ) { $image = array( 'id' => $image, ); } if ( ! $image ) { $thumbnail_id = get_term_meta( $brand->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = array( 'id' => $thumbnail_id, ); } }/wp-content/themes/woodmart/inc/shortcodes/brands.php
You must change this code:
$image = get_term_meta( $brand->term_id, 'image', true ); $filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $attribute ) ); if ( ! $image ) { $thumbnail_id = get_term_meta( $brand->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = array( 'id' => $thumbnail_id, ); } }With this code:
$image = get_term_meta( $brand->term_id, 'image', true ); $filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $attribute ) ); // Fix: If 'image' meta contains an attachment ID (numeric), convert to array format if ( $image && is_numeric( $image ) ) { $image = array( 'id' => $image, ); } if ( ! $image ) { $thumbnail_id = get_term_meta( $brand->term_id, 'thumbnail_id', true ); if ( $thumbnail_id ) { $image = array( 'id' => $thumbnail_id, ); } }Please check and confirm. Thank you
December 3, 2025 at 11:53 am #698940
MikeParticipantThe first code that i post for temporary fix in function.php it generates some warnings because when $single is true, WordPress tries to access $check[0], but my code returns an associative array without a [0] index.
The key fix is array( 0 => $converted ) — this creates a numerically indexed array so WordPress can access $check[0] without errors.
Updated code:
/** * Fix WooCommerce Brands image compatibility with Woodmart theme * Only affects product_brand taxonomy, safer and more performant */ add_filter( 'get_term_metadata', 'fix_woodmart_brand_image_format', 10, 4 ); function fix_woodmart_brand_image_format( $value, $object_id, $meta_key, $single ) { // Only process 'image' meta key when not already filtered if ( 'image' !== $meta_key || null !== $value ) { return $value; } // Only apply to product_brand taxonomy terms $term = get_term( $object_id ); if ( ! $term || is_wp_error( $term ) || 'product_brand' !== $term->taxonomy ) { return $value; } // Prevent infinite loop static $is_checking = array(); if ( isset( $is_checking[ $object_id ] ) ) { return $value; } $is_checking[ $object_id ] = true; $actual_value = get_term_meta( $object_id, $meta_key, true ); unset( $is_checking[ $object_id ] ); // Only convert if numeric (attachment ID) if ( $actual_value && is_numeric( $actual_value ) ) { return array( 0 => array( 'id' => (int) $actual_value ) ); } return $value; }December 3, 2025 at 2:54 pm #698998
Aizaz Imtiaz AwanKeymasterHello,
WooCommerce Brands uses a different image field than the old attribute brands.
Please go to: WooCommerce > Products > Brands
Edit each brand > Make sure a brand image is uploaded.
Then, navigate to Theme Settings > Shop > Brands > and make sure the product brand is assigned correctly.
Please check this manual: https://xtemos.com/docs-topic/product-brands/
If you have any questions, feel free to contact us.
Best Regards,
December 3, 2025 at 3:08 pm #699014
MikeParticipanti have already done that, and the problem persist. I show the the code that it fix the problem. You can just replicate the same on a stage site, so you can check it and maybe you create a better fix for that since i don’t know if the brand system affect anything else
December 4, 2025 at 10:52 am #699145
Aizaz Imtiaz AwanKeymasterHello,
I have checked it on our test site and WooCommerce brands are working fine in the WP Bakery.
See Screenshots for clarification:
https://ibb.co/4vN6SbL
https://ibb.co/7dGTjRdWPlease deactivate all the 3rd party plugins and activate only theme-required plugins on the site, and then check the issue. I am sure your issue will be solved. Then activate the 3rd party plugins one by one and check which plugin is creating the issue for you.
Otherwise, if the issue still exists, then keep the 3rd party plugins deactivated and share the WP login details, so I can check and give you a possible solution.
Best Regards,
-
AuthorPosts
- You must be logged in to create new topics. Login / Register