0

I went through Save and display specific payment gateway additional field everywhere in Woocommerce that displays an additional dropdown field for specific payment gateway in checkout page. But I need to show a text box instead of the drop down menu and save and show in orders, emails etc.

I have edit the code from the above link and made changes according to my ipg plugin, but it doesn't show.

add_filter( 'woocommerce_gateway_description', 'gateway_digitalipg_custom_fields', 20, 2 );
function gateway_digitalipg_custom_fields( $description, $payment_id ){
    //
    if( 'digitalipg' === $payment_id ){
        ob_start(); // Start buffering

        echo '<div  class="digital-ipg" style="padding:10px 0;">';

        woocommerce_form_field( 'digital-ipg', array(
            'type'          => 'select',
            'label'         => __("Fill in this field", "woocommerce"),
            'class'         => array('form-row-wide'),
            'required'      => true,
            'options'       => array(
                ''          => __("Select something", "woocommerce"),
                'Option 1'  => __("Choice one", "woocommerce"),
                'Option 2'  => __("Choice two", "woocommerce"),
            ),
        ), '');

        echo '<div>';

        $description .= ob_get_clean(); // Append buffered content
    }
    return $description;
}

the output was nothing i dont see any dropdowns on the cart when i select my ipg

Anas
  • 65
  • 8
  • Does this payment method exist? is it really working? Is this id correct? " if( 'digitalipg' === $payment_id ){ " – Kelvin Mariano Oct 31 '19 at 08:37
  • Yes the payment id is correct – Anas Oct 31 '19 at 09:13
  • see if this works and if it stops your application and shows the test message please --- if( 'digitalipg' === $payment_id ){ echo 'test'; exit(); ob_start(); // Start buffering – Kelvin Mariano Oct 31 '19 at 09:16
  • but it works for BACS and COD – Anas Oct 31 '19 at 09:18
  • If inside digitalipg is not working then your payment id is wrong, do this to detect the correct id: --- echo $payment_id; exit(); if( 'digitalipg' === $payment_id ){ ob_start(); // Start buffering – Kelvin Mariano Oct 31 '19 at 09:29

0 Answers0