You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"
Does this snippet (still) work?
Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.
If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)
Need Help with WooCommerce?
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
what page is the image source calling from so that instead of changing the filter (ie. add snippet in the functions) I can place/replace the code in the original file (ie.
<img src="mysite/*/img.png>
); whereby allowing me to use the theme I would like to use with all of the other plugins active.
Hello Sifat, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, go to WP Dashboard > WooCommerce > System Status: what errors do you see in red font?
I found out that my theme already was adding a filter to this hook and therefore was overriding my attempt to change the icon.
By adding a high priority (e.g 99) to my filter it worked nice.
Thanks Maira ๐ Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
It works perfectly. However, the logo I have is 159×55 but for some reason is displaying at 150×52 so looks slightly blurred.
I note you say this can be altered by CSS but as the image is being pulled from PayPal’s website I am not sure what to add to my style.css to make the necessary adjustments.
As an addition to the above, one concern I have is that if PayPay decide to change the image size will I need to update the CSS to reflect this or is there a way of showing the logo at the intended size automatically?
Cheers Bri ๐ In relation to your other questions, it’s difficult for me to give you an answer re: CSS without having your website checkout link. Also, if PayPal changes the image, yep, this will appear broken on your checkout. You can always download such image into your media library instead and avoid linking to PayPal in case! Hope this helps
// Change COD icon
function replaceCODicon($iconUrl) {
return 'https://img.jpg'; // change this to your IMAGE URL
}
add_filter('woocommerce_cod_icon', 'replaceCODicon');
I was so relieved to find this filter. I should’ve known it was you who created it! ๐ Thank you AGAIN for your fantastic contributions, Rodolfo. You make my life a whole lot easier.
Thank you Adriano. In relation to “about paypal” just take a look at the PayPal gateway file and see if there is a filter or hook to change that… otherwise you could hide that via CSS.
Questions? Feedback? Support? Leave your Comment Now! _____
If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)
With 100,000 (and growing) monthly organic sessions, Business Bloomer is the most consistent, most active and most complete WooCommerce development/customization blog.
Of course this website itself uses the WooCommerce plugin, the Storefront theme and runs on a WooCommerce-friendly hosting.
Hi, any solution to remove the icon not to replace it? Thank you,
Yes, you can slightly modify this snippet and try to return nothing
Actually, I run into the same issue as Sifat switching to Storefront as well. Here is what I get via inspecting page:
what page is the image source calling from so that instead of changing the filter (ie. add snippet in the functions) I can place/replace the code in the original file (ie.
); whereby allowing me to use the theme I would like to use with all of the other plugins active.
Thank you in advance
Respectfully
Hey Nathan, please don’t edit core files – this filter is great as you don’t have to do that ๐
I use this code but it’s not working . i tried localhost also live site not working .. can you please help me .?
add_filter( ‘woocommerce_paypal_icon’, ‘bbloomer_replace_paypal_icon’,99);
function bbloomer_replace_paypal_icon($iconUrl) {
return ‘https://localhost/wp-1/wp-content/uploads/2019/01/—.jpg’;
}
Hello Sifat, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?
To troubleshoot, go to WP Dashboard > WooCommerce > System Status: what errors do you see in red font?
Also, take a look at this tutorial to see how to troubleshoot: https://businessbloomer.com/woocommerce-troubleshooting-mistakes-to-avoid/
Finally, can you try switching temporarily to “Twentyseventeen” or “Storefront” theme and let me know if it works?
Hope this helps!
R
This is exactly what I added to my functions.php file but my cart still shows the standard PayPal icon.
Any suggestions?
Hey Paul! Are you working on the Cart or Checkout page?
The checkout page.
Hey Paul, it should work indeed. Can you try with another theme to see if it’s your current theme that is responsible for this error?
I found out that my theme already was adding a filter to this hook and therefore was overriding my attempt to change the icon.
By adding a high priority (e.g 99) to my filter it worked nice.
So, try to add 99 at the end and see what happens!
Good luck!
Nice, thank you ๐
I really appreciate the help you have provided but this snippet doesn’t seem to be working for me.
Hey Paul, thanks for your comment! I just tested this on Woo 3.2.5 and Storefront and still works perfectly ๐
Hi Rodolfo, your WC tutorials are the most helpful I’ve found in a long time, so thank you so much for sharing!
I have a question, is it possible to add a custom icon/logo to the COD payment method? Been searching with no luck ๐
Thanks Maira ๐ Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
thanks a lot, it works prefectly
Awesome ๐
This code is not working for me could please helm me..?
Hey Mounish, thanks for your comment! What image URL are you using in your snippet?
Hi, Thank you for this snippet.
It works perfectly. However, the logo I have is 159×55 but for some reason is displaying at 150×52 so looks slightly blurred.
I note you say this can be altered by CSS but as the image is being pulled from PayPal’s website I am not sure what to add to my style.css to make the necessary adjustments.
As an addition to the above, one concern I have is that if PayPay decide to change the image size will I need to update the CSS to reflect this or is there a way of showing the logo at the intended size automatically?
Thanks in advance.
Cheers Bri ๐ In relation to your other questions, it’s difficult for me to give you an answer re: CSS without having your website checkout link. Also, if PayPal changes the image, yep, this will appear broken on your checkout. You can always download such image into your media library instead and avoid linking to PayPal in case! Hope this helps
Hi thank you how do you change the size of the image
Hey Chilly, thanks so much for your comment! Image size can be changed via simple CSS, are you familiar with that?
very nice man, how to set cash on delivery using any images….could you help me….
You’re welcome Siva! For “cod”, you can use this:
Let me know ๐
I was so relieved to find this filter. I should’ve known it was you who created it! ๐ Thank you AGAIN for your fantastic contributions, Rodolfo. You make my life a whole lot easier.
Thank you Sharon for your amazing feedback ๐
Hi. Thanks for the article, it’s really helpful! Is there a way to also return the link text “about paypal” that lies right beside the icon?
Thank you Adriano. In relation to “about paypal” just take a look at the PayPal gateway file and see if there is a filter or hook to change that… otherwise you could hide that via CSS.