Site logo

Archived topic

change the add to cart button to an icon when viewing it from a mobile

2 replies · Started by WALTER on April 5, 2020

Viewing posts 1–3 of 3

i need help to change the style of my cart button, I want to replace it with a cart icon

current view
null

I would like it to look like this on the phone
expectation

and on the pc I would like it to look like this

in pc

Hi there,

first you need to add this PHP Snippet to change the Buy Button text:

add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Compra', 'woocommerce' );
}

Then add this CSS and update the background-image URL with your cart icon:

.woocommerce ul.products li.product .button:before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    background-image: url('url_to_my_cart_image/image.png');
    margin-right: 1ch;
}
@media (max-width: 768px) {
    .woocommerce ul.products li.product .button {
        font-size: 0;
    }
}
This archived topic is closed to new replies.