如何更改 WooCommerce / WooCommerce PayPal 付款插件中付款选项的徽标
我有一个名为 WooCommerce PayPal Payments
的插件,它允许在 WooCommerce
中进行 PayPal
付款。有了这个插件,他们还可以选择信用卡
付款。参见下文:
所有这些都会在前端呈现以下内容:
现在,我正在尝试更改 AMEX 徽标为自定义徽标。
我看过很多文章介绍如何更改 PayPal
徽标,比如这个,但没有看到任何提及如何更改 AMEX、MasterCard 或其他徽标的内容。
例如,我使用此挂钩来更改 PayPal
徽标:
add_filter( 'woocommerce_gateway_icon', 'remove_what_is_paypal', 10, 2 );
function remove_what_is_paypal( $icon_html, $gateway_id ) {
if( 'paypal' == $gateway_id ) {
$paypal_logo = get_template_directory_uri()."/assets/build/vectors/paypal-logo-original.svg";
$icon_html = "<img class='checkoutPage__paypal' src=".$paypal_logo."' alt='PayPal logo'>";
}
return $icon_html;
}
How do I Change the AMEX
logo?
I have a plugin called WooCommerce PayPal Payments
which allows PayPal
payments in WooCommerce
. With this plugin, they also have an option for credit card
payments. See below:
All of this renders the following on the front end:
Now, I'm trying to change the AMEX
logo to a custom logo.
I've seen many articles which show how to change the PayPal
logo, such as this one, but haven't seen any that mention how to change the AMEX, MasterCard or other logo.
For example, I've used this hook to change the PayPal
logo:
add_filter( 'woocommerce_gateway_icon', 'remove_what_is_paypal', 10, 2 );
function remove_what_is_paypal( $icon_html, $gateway_id ) {
if( 'paypal' == $gateway_id ) {
$paypal_logo = get_template_directory_uri()."/assets/build/vectors/paypal-logo-original.svg";
$icon_html = "<img class='checkoutPage__paypal' src=".$paypal_logo."' alt='PayPal logo'>";
}
return $icon_html;
}
How do I change the AMEX
logo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据要求更改返回 URL。
卡片数组插件中没有过滤器来更改个人的图标。 AFAIK 这是唯一可以在这种情况下使用的钩子。
Change the return URL as per the requirement.
There is no filter in the plugin to the cards array to change the icon for individuals. AFAIK this is the only hook that can be used in this situation.
代码位于活动子主题(或活动主题)的 function.php 文件中。经过测试并有效。
Code goes in function.php file of your active child theme (or active theme). Tested and works.
显然,由于没有用于更改此网关的 html(尤其是信用卡图标)的过滤器,因此您可能不得不求助于 CSS 组合。
您可以使用以下代码隐藏或覆盖 AMEX 图像,并将其替换为与伪元素背景相同的图像。用一些不同的图像替换它就像将背景图像 url 替换为您想要使用的图像一样简单:
我会等待应用最后一行,这甚至可能没有必要,直到我完成位置和调整大小以使新图像看起来恰到好处。当然,您需要仔细检查独特的主题特征和响应能力,但无论如何都有这个概念。
Since there is not, apparently, a filter for altering this gateway's html, or specifically the credit card icons, you might have to resort to a CSS kludge.
You could use the following code to hide or cover the AMEX image, and replace it with the same image as pseudo-element background. Replacing it with some different image would be as simple as replacing the background-image url with the one you want to use:
I'd wait to apply the last line, which may not even be necessary, until I'd finished making position and size nudges to get the new image looking just right. Naturally, you'd want to double check against unique theme characteristics and for responsiveness, but anyway there's the concept.