search ]

Change Payment Icons on WooCommerce Checkout

Here is an example of how to change the default PayPal icon on the WooCommerce checkout page. Live example:

<?php
/**
 * Add custom gateway icons
 * 
 * @param  string $icon       Image HTML.
 * @param  string $gateway_id Gateway ID.
 * 
 * @return string
 */
function custom_wc_gateway_icons( $icon, $gateway_id ) {
	// Example for PayPal:
	if ( 'paypal' == $gateway_id ) {
		$icon = '<img src="' . WC_HTTPS::force_https_url( 'http://your-site.com/image.png' ) . '" alt="' . __( 'PayPal' ) . '" />'
	}
	return $icon;
}
add_filter( 'woocommerce_gateway_icon', 'custom_wc_gateway_icons', 10, 2 );

For a complete WooCommerce setup guide, see Create a Virtual Store with WooCommerce.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo