A
A
Alexey2017-09-27 10:19:55
WordPress
Alexey, 2017-09-27 10:19:55

How to change the style of the "in the cart" button?

Hello, how can I change the style of the "add to cart" button in woocommerce (for example, change the color) for a product that is already in the cart? I know that there is a hook for changing the text of a button, but is there a hook for editing a tag or its styles, or something like that? The theme is storefront.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Travkin, 2017-09-27
@PavelsT01

There, most likely, the button will have class .added

O
one_day, 2017-09-27
@one_day

hook to change the text on the button, jsom search for this text and add style to the element

add_filter( 'add_to_cart_text', 'woo_custom_product_add_to_cart_text' );            // < 2.1
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text' );  // 2.1 +
  
function woo_custom_product_add_to_cart_text() {
    return __( 'My Button Text', 'woocommerce' );
}

setInterval(function(){
$('a:contains("My Button Text")').css('border', '1px solid red');
},1000);

L
Lumore, 2017-09-27
@Lumore

.add_to_cart_button {
    background: #1abc9c !important;
}

You have a mess with CSS code on the page, it's better to separate it into different files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question