WooCommerce: How to Remove “What is PayPal?” @ Checkout

One of my premium course students had an apparently simple requirement. Her client didn’t want to show the “What is PayPal?” text (and link) on the checkout page. In fact, why sending users away from the checkout? And who doesn’t know what PayPal is nowadays?Β Well, let’s see how this isΒ done via a simple “filter” – but this time I’d like to show you a step-by-step tutorial! Let me know what you think about this in the comments πŸ™‚

WooCommerce "What is PayPal" at checkout
WooCommerce “What is PayPal” at checkout

1. WooCommerce Plugin File Search

First, we try to find where this “What is PayPal” is generated from, usually a PHP function. In fact, this is what shows in the woocommerce\includes\gateways\paypal\class-wc-gateway-paypal.php file:


/**
 * Get gateway icon.
 * @return string
 */
	
public function get_icon() {
	$icon_html = '';
	$icon      = (array) $this->get_icon_image( WC()->countries->get_base_country() );

	foreach ( $icon as $i ) {
		$icon_html .= '<img src="' . esc_attr( $i ) . '" alt="' . esc_attr__( 'PayPal Acceptance Mark', 'woocommerce' ) . '" />';
	}

	$icon_html .= sprintf( '<a href="%1$s" class="about_paypal" onclick="javascript:window.open(\'%1$s\',\'WIPaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\'); return false;" title="' . esc_attr__( 'What is PayPal?', 'woocommerce' ) . '">' . esc_attr__( 'What is PayPal?', 'woocommerce' ) . '</a>', esc_url( $this->get_icon_url( WC()->countries->get_base_country() ) ) );

	return apply_filters( 'woocommerce_gateway_icon', $icon_html, $this->id );
}

2. Boom! The function is “filterable”

WooCommerce gives us this, so that we can “filter” or “edit” the behavior of such function without having to override WooCommerce core files:


return apply_filters( 'woocommerce_gateway_icon', $icon_html, $this->id );

3. Let’s find the HTML code that we need to filter

Now that we know the function is editable via a hook (filter), we find out that the “What is PayPal” link is added by the variable $icon_html.


$icon_html .= sprintf( '<a href="%1$s" class="about_paypal" onclick="javascript:window.open(\'%1$s\',\'WIPaypal\',\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700\'); return false;" title="' . esc_attr__( 'What is PayPal?', 'woocommerce' ) . '">' . esc_attr__( 'What is PayPal?', 'woocommerce' ) . '</a>', esc_url( $this->get_icon_url( WC()->countries->get_base_country() ) ) );

Please note the “.=”: this means $icon_html is being concatenated to the previous $icon_html, which contains the PayPal image:


$icon_html .= '<img src="' . esc_attr( $i ) . '" alt="' . esc_attr__( 'PayPal Acceptance Mark', 'woocommerce' ) . '" />';

4. Let’s code the PHP snippet: How to Remove “What is PayPal?” @ Checkout

Now that we have all the information, let’s start coding. Take a look at the comments in the PHP snippet to see if you can follow me.


/**
 * @snippet       WooCommerce Remove "What is PayPal?" @ Checkout
 * @how-to        businessbloomer.com/woocommerce-customization
 * @sourcecode    https://businessbloomer.com/?p=21186
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 3.5.4
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_gateway_icon', 'bbloomer_remove_what_is_paypal', 10, 2 );

function bbloomer_remove_what_is_paypal( $icon_html, $gateway_id ) {
if( 'paypal' == $gateway_id ) {
   $icon_html = '<img src="/wp-content/plugins/woocommerce/includes/gateways/paypal/assets/images/paypal.png" alt="PayPal Acceptance Mark">';
}
return $icon_html;
}

5. Summary

To summarize:

1) I’m calling the filter with: add_filter( ‘woocommerce_gateway_icon’, …
2) I’m creating my custom override function ‘bbloomer_remove_what_is_paypal’
3) I’m passing to the function two variables: the HTML ($icon_html) and the gateway name ($gateway_id), as we need to make sure we override those through the filter
4) I make sure this is the PayPal gateway with the if > then
5) I edit the $icon_html variable, by just saying “trash the previous, use mine instead”
6) I return $icon_html to the system

Let me know in the comments if this “extended” tutorial helps πŸ™‚

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

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

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

24 thoughts on “WooCommerce: How to Remove “What is PayPal?” @ Checkout

  1. Thank you! The code What is my PayPal text was actually pushing the PayPal Credit card image over the text selection “PayPal” which looked really bad for new customers that want to put trust into a website. Happy to say that it worked like a charm. Nice work Rodolfo!

    1. Thanks Andrew!

  2. Great tip – though it still leaves the credit card image to the right, and the black box the “What is PayPal?” text used to be in.

    1. Hey Ian, thanks so much for your comment! You’re right, but this snippet is not meant to hide the image, only the “What is PayPal”. In regard to the black box, that must be your theme or custom CSS, as this is not present in default WooCommerce – you might need to add some custom CSS line as well πŸ™‚

  3. Man… you’re a genious… big thanks !

    1. Thanks a lot πŸ™‚

  4. Thank for this but just one question. How do I replace the whole “Paypal: What is Paypal” with something like: Credit, Debit cards and Paypal.

    Unfortunately, some people still think you need a paypal account to pay. I want it to be made more clear that you don’t need one without clicking on the pay with paypal option (brings up the “you don’t need an account text”). Really wish paypal themselves would think about this and integrate it.

    1. Dave, thanks so much for your comment! 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

  5. This is not working with woo commerce 3.2.3. Can u please check . Thanks

    1. Hey Kumar, thanks for your comment. Positive, it works on the latest WooCommerce version. Make sure you’re only using the code at paragraph 4, the previous code is only to demonstrate the snippet coding.

  6. Or you could just add the css:

    .about_paypal {
        display: none;
    }
    
    1. Matt, thanks so much for your comment! Using display: none is not a great idea if PHP can be used for that. Element will still be there despite you hide it, while with PHP it doesn’t even load πŸ™‚

      1. I disagree in this instance. What happens when Woocommerce release an update and the PayPal logo is updated (like it actually has been since this article)? You aren’t going to know that image has been replaced and will manually need to updated the PHP function.

        For the sake of hiding a tiny link, i’d personally opt for hiding it with CSS & ensuring the payment logo is always valid & up to date.

        1. Good point. Best would be to replace it with your own image, stored in your Media folder

          1. genius!!! Would you also help with how we can add to this to remove the PayPal image via css as well?

            1. Hi Xenia, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  7. Hey, does this work with Woocommerce 3.x?

    Thanks!

    krko

    1. Krko, thanks for your comment! It should – have you tried yet?

  8. Hi..! It worked me. Thank you.

  9. Thanks . It worked for me.

    1. Thank you Kumar πŸ™‚

  10. HI Rodolfo! Thanks a lot for your blog and all the free amazing resource you share for free – it’s been such a big help for me πŸ™‚ However, there is one question I’ve not be able the find the answer to. Maybe you can help. I’d really like to remove the ‘slide effect’ from the product gallery on the product page in woocommerce. I find it really annoying that the product images rotate in an endless loop, even if I chose a specific product (images) it automatically move away from it. Can this somehow be fixed? Many thanks, Denice

    1. Hello Denice, thanks so much for your comment & feedback. In regard to your issue, are you sure this is not a theme-related problem? Based on your description I don’t recall this behavior on the default WooCommerce – if yes maybe give me a link or send me a screenshot to being able to understand your point πŸ™‚ Cheers!

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!

Your email address will not be published. Required fields are marked *