Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce: Add class to notice

I want to add an extra class to my WooCommerce notice.

Here's my current code for printing the notice:

wc_print_notice( 'My message', 'success' );

I saw in the WooCommerce Docs, that there is an option to add extra $data to the notice.

But something like this won't work (it adds only data-class="extra" to it):

wc_print_notice( 'My message', 'success', array('class' => 'extra') );

Is there an option to do this or am I misunderstanding something?

like image 598
Cray Avatar asked Dec 05 '25 17:12

Cray


1 Answers

I found an optional solution for my case. It would be possible to simply style the notice with the data attribute. Like this:

.woocommerce-message[data-class="extra"] {
    background-color: red;
}
like image 115
Cray Avatar answered Dec 08 '25 08:12

Cray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!