Created
March 2, 2021 15:52
-
-
Save h2kyaw/a43aec1c1fad5a6adb4178953f9c0148 to your computer and use it in GitHub Desktop.
Revisions
-
h2kyaw created this gist
Mar 2, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ add_filter( 'woocommerce_gateway_icon', 'custom_payment_gateway_icons', 10, 2 ); function custom_payment_gateway_icons( $icon, $gateway_id ){ foreach( WC()->payment_gateways->get_available_payment_gateways() as $gateway ) if( $gateway->id == $gateway_id ){ $title = $gateway->get_title(); break; } // The path (subfolder name(s) in the active theme) $path = get_stylesheet_directory_uri(). '/assets/images/payment'; // Setting (or not) a custom icon to the payment IDs if($gateway_id == 'bacs') $icon = '<img src="' . WC_HTTPS::force_https_url( "$path/direct-bank.png" ) . '" alt="' . esc_attr( $title ) . '" />'; elseif( $gateway_id == 'cheque' ) $icon = '<img src="' . WC_HTTPS::force_https_url( "$path/bank-check.png" ) . '" alt="' . esc_attr( $title ) . '" />'; elseif( $gateway_id == 'cod' ) $icon = '<img src="' . WC_HTTPS::force_https_url( "$path/cash-on-delivery.png" ) . '" alt="' . esc_attr( $title ) . '" />'; elseif( $gateway_id == 'ppec_paypal' || 'paypal' ) return $icon; return $icon; }