3

I am trying to remove or edit the "sale!" badge is in woocommrce loop enter image description here

In the content-product.php, the comment block says the woocommerce_show_product_loop_sale_flash is hooked with woocommerce_before_shop_loop_item.

However it actually works with woocommerce_after_shop_loop_item_title. enter image description here

I tried to remove everything from the hook, still, the sales badge still appears:

remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating' );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price' );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );

The following is also not working:

remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );

So I really have no idea where the sales badge function is being called from?

adrian li
  • 457
  • 8
  • 19

1 Answers1

1

I'm not sure why it's not working for you, because all you have to do is use remove_action, the parameters are the hook location being used and the action name. In this case:

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );

This works, I checked. I was looking for the same thing. Just add it to your functions.php file. It removes the action called woocommerce_show_product_loop_sale_flash from being hooked into the woocommerce_before_shop_loop_item_title hook location.

Perhaps there is a plugin putting it there as well?

In my case, I did not want the sale flash to be inside of the link so I moved it up to be a direct child of the li instead. I did this by first removing the action via the above, and then adding a new action with a new hook location. The new hook location is the same as the one used to open the link, so I had to modify the priority number to make sure it was executed before the link action sharing the hook.

add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash', 5 );
MDoulos
  • 13
  • 3