PHP Weekly Discussion (September)

This will probably be the most elementary questions this thread has ever received, but i'm desperate for help and have wasted so many hours. I am building an ecommerce website. I've been tweaking the CSS and adding PHP into Code Snippets plugin to get the website to look the way I want to look. Here are the two things that for the life of me, I cannot figure out.

  1. I am using the latest version of WooCommerce along with Stripe. There are two payment icons (JCB, Diner's Club) that I would like removed. It's too many icons for mobile display. I tried using some simple CSS such as display:none to achieve this. It looks great on mobile, but not on desktop because there is a gap in space where the icons are hidden. I need PHP code that I can input and remove those icons. There are a couple of articles online, but they are reference older versions of Stripe/Woo so they don't work for me. Here is an example of the code I was trying:

function rs_removed_icon( $icons ) {

$icons = str\_replace( '<img src="[https://trendypupstore.com/wp-content/plugins/woocommerce-gateway-stripe/assets/images/icons/credit-cards/jcb.svg](https://trendypupstore.com/wp-content/plugins/woocommerce-gateway-stripe/assets/images/icons/credit-cards/jcb.svg)" alt="JCB" width="32" style="margin-left: 0.3em" />', '', $icons );

$icons = str\_replace( '<img src="[https://trendypupstore.com/wp-content/plugins/woocommerce-gateway-stripe/assets/images/icons/credit-cards/diners.svg](https://trendypupstore.com/wp-content/plugins/woocommerce-gateway-stripe/assets/images/icons/credit-cards/diners.svg)" alt="Diners" width="32" style="margin-left: 0.3em" />', '', $icons );

return $icons;

}

add_filter( 'woocommerce_gateway_icon', 'rs_removed_icon');

  1. I am trying to change my Add to Cart button on all of my variable products from gray to black. The apple pay button is solid black, and my button would look better if the colors matched. I have tried several CSS rules to achieve this, but all I've managed to achieve was having the button turn black after a size has been selected. Is there a PHP rule I can write to override it being gray before a size is selected? I might be able to just go into Woo and select a default size so one is automatically selected, but I haven't tried it yet.

Any help is greatly appreciated. Thank you in advance. I wouldn't have written this post if I hadn't tried hard to solve this prior.

/r/PHP Thread