Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created July 21, 2014 17:00
Show Gist options
  • Save claudiosanches/9db17583210a769f08b5 to your computer and use it in GitHub Desktop.
Save claudiosanches/9db17583210a769f08b5 to your computer and use it in GitHub Desktop.
WooCommerce - Custom gateway icons
<?php
/**
* Add custom gateway icons
*
* @param string $icon Image HTML.
* @param string $gateway_id Gateway ID.
*
* @return string
*/
function custom_wc_gateway_icons( $icon, $gateway_id ) {
// Example for PayPal:
if ( 'paypal' == $gateway_id ) {
$icon = '<img src="' . WC_HTTPS::force_https_url( 'http://your-site.com/image.png' ) . '" alt="' . __( 'PayPal' ) . '" />'
}
return $icon;
}
add_filter( 'woocommerce_gateway_icon', 'custom_wc_gateway_icons', 10, 2 );
@trsprod
Copy link

trsprod commented Jul 20, 2016

Hello Claudio,

i wanted to ask you something.
This is a part of the Code for my custom Payment Gateway:

public function __construct(){
    $this->id = 'other_payment';
    $this->method_title = __('Custom Payment','woocommerce-other-payment-gateway');
    $this->title = __('Custom Payment','woocommerce-other-payment-gateway');
    $this->has_fields = true;
    $this->init_form_fields();
    $this->init_settings();
    $this->enabled = $this->get_option('enabled');
    $this->title = $this->get_option('title');
    $this->description = $this->get_option('description');
    add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, `'process_admin_options'));`

How do i add a custom icon to my custom payment gateway?
Ive understood to replace to replace the URL...but i dont get how to add the gateway_id or which one i have to add....what do i have to do exactly?

Thanks...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment