CSS issue with Add to Cart button
-
I’ve used the following code in functions.php to remove the “Add to Cart” buttons on Shop Category pages, and replace with “Learn More” buttons that link to the product pages –
/* REMOVE ADD TO CART BUTTON ON PRODUCT ARCHIVE (SHOP) */ function remove_loop_button(){ remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); } add_action('init','remove_loop_button'); /* ADD NEW BUTTON THAT LINKS TO PRODUCT PAGE FOR EACH PRODUCT */ add_action('woocommerce_after_shop_loop_item','replace_add_to_cart'); function replace_add_to_cart() { global $product; $link = $product->get_permalink(); echo do_shortcode('<a href="'.$link.'" class="learnmorebutton">Learn more</a>'); }
This worked well and produced red buttons with white text as in this pic –
My problem now is in styling these buttons. I’ve included a custom style called “learnmorebutton” in the style sheet for my child theme as follows –
.woocommerce .learnmorebutton { background-color: #F7A919; color: #ffffff; border-radius: 3px; padding: 5px 10px 5px 10px; display: inline-block; font-family: inherit; font-size: 100%; line-height: 1; text-decoration: none;
This works for the colour, padding and radius of the button, but I don’t seem to be able to impact on the text colour. I’ve specified white, but as you can see from this page, it shows as black! https://internetsquad.co.uk/product-category/books/
CSS is not my strong point, so I’d appreciate any guidance as to how to change the text colour for these buttons.
Here’s a link to the custom CSS in my child theme in case there’s something else causing an issue – https://pastebin.com/BpQ7vQPv
A lot of this CSS I did quite some time ago, so I’m not sure what the CSS starting between line 32 and line 51 is supposed to control? I’ve changed background-color: a few times, but I can’t see anything changing in my WooCommerce pages!
Hope someone can help.
Myles
- The topic ‘CSS issue with Add to Cart button’ is closed to new replies.