Add/remove credit card icon on Stripe plugin
On Credit card form, on checkout page, the plugin show a list of icons of credit cards allowed on stripe.
This list of icons can be changed through hook available on WooCommerce:
add_filter( 'woocommerce_gateway_icon', 'my_function');
So, you should simple add a function that change the HTML of the icons.
Here some examples:
Add an icon
function my_add_icon( $icons ) {
$icons .= '<img style="width: 40px;" src=" . WC_HTTPS::force_https_url( 'http:/{{url-to-your-icon-image}}' ) . '" alt="{{card-name}}" />';
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'my_add_icon');
Where {{url-to-your-icon-image}} is the absolute URL to the icon image you want to add and {{card-name}} is the name of card.
Remove an icon
function my_remove_icon( $icons ) {
$icons = str_replace( '<img style="width: 40px;" src=" . WC_HTTPS::force_https_url( 'http:/{{url-to-your-icon-image}}' ) . '" alt="{{card-name}}" />', '', $icons );
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'my_remove_icon');
Change an icon
function my_change_icon( $icons ) {
// icon to remove in replace of the newest
$icon_to_replace = '<img style="width: 40px;" src=" . WC_HTTPS::force_https_url( 'http:/{{url-to-your-icon-image}}' ) . '" alt="{{card-name}}" />';
// icon to remove in replace of the newest
$new_icon = '<img style="width: 40px;" src=" . WC_HTTPS::force_https_url( 'http:/{{url-to-your-icon-image}}' ) . '" alt="{{card-name}}" />';
$icons = str_replace( $icon_to_replace, $new_icon, $icons );
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'my_change_icon');