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, where {{card-name-image}} is the name of the icon image and {{card-name}} is the name of card.
Add an icon
function my_add_icon( $icons ) {
$icons .= '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/{{card-name-image}}.png' ) . '" alt="{{card-name}}" style="width:40px;" />';
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'my_add_icon');
Remove an icon
function my_remove_icon( $icons ) {
$icons = str_replace( '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/{{card-name-image}}.png' ) . '" alt="{{card-name}}" style="width:40px;" />', '', $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 src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/{{card-name-image}}.png' ) . '" alt="{{card-name}}" style="width:40px;" />';
// icon to remove in replace of the newest
$new_icon = '<img src="' . WC_HTTPS::force_https_url( WC()->plugin_url() . '/assets/images/icons/credit-cards/{{card-name-image}}.png' ) . '" alt="{{card-name}}" style="width:40px;" />';
$icons = str_replace( $icon_to_replace, $new_icon, $icons );
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'my_change_icon');