How we created a message on woo-commerce products for a specific brand

My client is currently dealing with product shortages for a specific brand and wanted us to create a message to declare this under their product images so we managed to create this using the following WordPress function

In this example, we’re using the wp_get_post_terms function to retrieve the brands associated with the current product. We’re passing pwb-brand taxonomy as the first argument, which is the taxonomy used by the Product Brands for the WooCommerce plugin.

We’re then looping through each brand and checking if its slug matches the slug of the specific brand we want to display the notice for. If a match is found, the notice will be displayed.

You can replace 'your-brand-slug' with the slug of the specific brand that you want to display the notice for.

This code will add the notice under the product image on the single product page in WooCommerce for the specified brand.

This function adds a hook under the product image and outputs the text “SHORTAGES IN SOME AREAS MAY AFFECT DELIVERY” for a specific WooCommerce brand.

function show_shortages_notice() {
  global $product;
  $product_brands = wp_get_post_terms( $product->get_id(), 'product_brand', array('fields' => 'all') );
  foreach( $product_brands as $brand ) {
    if ( $brand->slug == 'your-brand-slug' ) {

add_action( 'woocommerce_single_product_summary', 'show_shortages_notice', 25 );

Leave a Comment

Your email address will not be published.

Scroll to Top