Search code examples
phpwordpresswoocommercepayment-gatewayskrill

Add WC_Payment_Gateway description to Woocommerce option payment with Skrill plugin


I'm using the skrill plugin for electronic payments. the plugin plugin, however, does not give me the possibility to add a description to the payment method, how can I do it using the function file? I tried to use the code on this page:

Additional field on checkout for specific payment gateway in Woocommerce

but it does not work, how can I do?


Solution

  • The hook woocommerce_gateway_description can't work for SKRILL payment options as WC_Payment_Gateway get_description() is not defined in SKRILL plugin code.

    So you shuld need to tweak it differently to have a description for SKRILL payment options in Woocommerce checkout page, this way:

    add_filter( 'woocommerce_gateway_icon', 'gateway_skrill_description', 10, 2 );
    function gateway_skrill_description( $icon, $payment_id ){
        if ( \strpos($payment_id, 'skrill') !== false ) {
            $description_text = __("You can pay with your credit card if you don’t have a SKRILL account...", "woocommerce");
            $icon .= '</label><div class="payment_box payment_method_'.$payment_id.'" style="display:none;"><p>'.$description_text.'</p></div>';
        }
        return $icon;
    }
    

    Code goes in function.php file of your active child theme (or active theme). tested and works.

    enter image description here