This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Cart and Checkout on the Same Page This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
WooCommerce: Disable Payment Method If Product Category @ Cart Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
WooCommerce: Add Privacy Policy Checkbox @ Checkout Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]
WooCommerce: Redirect to Custom Thank you Page How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]
WooCommerce: Disable Payment Gateway by Country You might want to disable PayPal for non-local customers or enable a specific gateway for only one country… Either way, this is a very common requirement for all of those who trade internationally. Here’s a simple snippet you can further customize to achieve your objective. Simply pick the payment gateway “slug” you want to disable/enable […]
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. Follow @rmelogli
30 thoughts on “WooCommerce: Change the PayPal Icon @ Checkout Page”
Virgil
Hi, any solution to remove the icon not to replace it? Thank you,
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? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!
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.