替换结帐页面上的WooCommerce PayPal结帐网关插件图标 [英] Replace icon on checkout page for WooCommerce PayPal Checkout Gateway Plugin
问题描述
我正在使用WooCommerce的"WooCommerce PayPal Checkout Gateway"插件,并且希望在结帐页面上的付款选项"部分中使用自定义图像.
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.
我尝试了以下方法,但均无济于事;我认为它们可能是针对不使用插件的默认PayPal实现的?
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 ...
..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;
}
}
有一种简单的方法吗?
推荐答案
对于Woocommerce默认的Paypal付款网关,您将仅使用以下内容:
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" />';
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
对于插件 WooCommerce PayPal Checkout付款网关,请尝试此(正确的付款方式ID为 ppec_paypal
):
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;
}
代码进入您的活动子主题(或活动主题)的function.php文件中.经过测试,可以正常工作.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
这篇关于替换结帐页面上的WooCommerce PayPal结帐网关插件图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!