Link to home
Start Free TrialLog in
Avatar of derrida
derrida

asked on

How can i change classes on woocommerce buttons with filter hooks

hi
all i need is the change the classes on the woocommerce buttons, for example the add to cart button. i want to do it with filter functions.
i have searched and found overriding css, i want to use the filter functions to do it, i assume one can use str_replace, but not sure how exactly.

best regards
Avatar of derrida
derrida

ASKER

Anyone?
Avatar of derrida

ASKER

well i managed to change classes to buttons in the loop but cannot find what i need to hook to for the single product add to cart button:

add_filter( 'woocommerce_loop_add_to_cart_args','boottheme_change_loop_buttons_classes' );
function boottheme_change_loop_buttons_classes( $button ) {

    $button['class'] = str_replace('button','waves-effect waves-light btn',$button['class']);
    return $button;
}

Open in new window


any idea?
by the way, this is the first time i post a question and get no responses at all, not even asking for clarifications.
Avatar of Julian Hansen
Why not just override it in CSS?
Avatar of derrida

ASKER

hey julian
because i am using materialize and instead of recreating a look i can just give the right classes. so the look is consistent and actually easier to change.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.