Reputation: 20049
I'm using WooCommerce's "WooCommerce PayPal Checkout Gateway" plugin and I would like to use a custom image for where it display in the payment options section on the checkout page.
I have tried the below but neither work; I figure they may be for the default PayPal implementation they have without using a plugin?
add_filter( 'woocommerce_paypal_icon', 'my_replace_paypal_icon', 99 );
function my_replace_paypal_icon() {
return 'https://your_image_url';
}
..and...
add_filter( 'woocommerce_gateway_icon', 'my_paypal_gateway_icon', 10, 2 );
function paypal_gateway_icon( $icon, $id ) {
if ( $id === 'paypal' ) {
return '<img src="' . get_bloginfo('stylesheet_directory') . '/images/woocommerce-icons/cards.png" alt="Authorize.net" />';
} else {
return $icon;
}
}
Is there an easy way to do this?
Upvotes: 2
Views: 2144
Reputation: 254231
For Woocommerce default Paypal payment gateway, you will use exclusively the following:
add_filter( 'woocommerce_paypal_icon', 'custom_paypal_icon', 10, 2 );
function custom_paypal_icon( $icon ) {
return '<img src="' . get_bloginfo('stylesheet_directory') . '/images/woocommerce-icons/cards.png" alt="Paypal" />';
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
For the plugin WooCommerce PayPal Checkout Payment Gateway, try this (the correct payment method Id is ppec_paypal
):
add_filter( 'woocommerce_gateway_icon', 'custom_payment_gateway_icons', 10, 2 );
function custom_payment_gateway_icons( $icon, $gateway_id ){
// For Paypal Checkout (or Paypal Express) only
if( $gateway_id == 'ppec_paypal' ) {
$icon = '<img src="' . get_bloginfo('stylesheet_directory') . '/images/woocommerce-icons/cards.png" alt="Paypal Express" />';
}
return $icon;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Upvotes: 1