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        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=21186
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.5.4
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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 this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

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.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

20 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 πŸ™‚

  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? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.