Guest User

Add custom badge to WooCommerce featured product

a guest
Jun 12th, 2020
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Add custom badge to WooCommerce featured product.
  3.  */
  4. function wpsimpel_add_featured_product_badge() {
  5.  
  6.     global $product;
  7.  
  8.     if ( $product->is_featured() ) {
  9.         echo '<span class="product-badge custom-badge">' . esc_html_e( 'Featured product', 'your-text-domain' ) . '</span>';
  10.     }
  11. }
  12. add_action( 'woocommerce_before_shop_loop_item_title', 'wpsimpel_add_featured_product_badge' );
  13. add_action( 'woocommerce_before_single_product_summary', 'wpsimpel_add_featured_product_badge' );
RAW Paste Data