skip to Main Content

Please guys,

1° i’m trying to create a custom field to BACS account details page (Admin Area), so can i display in my thankyou page and the same time send per e-mail.

2° i’m following what this article says, but i think i’m doing something not correct

https://docs.wpdebuglog.com/plugin/woocommerce/4.0.0/filter/woocommerce_bacs_account_fields/

3° When i refresh the page, i get error messages in the debug.log file as follows:

C:xampppserver2htdocsmrdigitalwp-contentthemesastra-childfunctions.php on line 1853
[22-Oct-2020 21:04:51 UTC] PHP Parse error:  syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting variable (T_VARIABLE) in C:xampppserver2htdocsmrdigitalwp-contentthemesastra-childfunctions.php on line 1853

[22-Oct-2020 21:04:51 UTC] PHP Parse error:  syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting variable (T_VARIABLE) in C:xampppserver2htdocsmrdigitalwp-contentthemesastra-childfunctions.php on line 1853

[22-Oct-2020 21:06:18 UTC] PHP Parse error:  syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting variable (T_VARIABLE) in C:xampppserver2htdocsmrdigitalwp-contentthemesastra-childfunctions.php on line 1853

[22-Oct-2020 23:39:06 UTC] PHP Parse error:  syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting variable (T_VARIABLE) in C:xampppserver2htdocsmrdigitalwp-contentthemesastra-childfunctions.php on line 1853

This is the line 1853

function custom_woocommerce_bacs_account_fields( $array, value => $bacs_account_bank_name), account_number => array, value => $

4° i also tried the example from this article, but i also got error messages.(something made incorrect)

http://hookr.io/plugins/woocommerce/3.0.6/filters/woocommerce_bacs_account_fields/#

In summary, i need to create a new custom field like this:

'pid'           => array(
 'label' => __( 'PID', 'woocommerce' ),
 'value' => $bacs_account->pid,
), 

This is whole script that i’m trying – functions.php :

Gratitude for any help!

$account_fields = apply_filters(
                    'woocommerce_bacs_account_fields',
                    array(
                        'account_name'      => array(
                            'label' => __( 'Nome da Conta', 'woocommerce' ),
                            'value' => $bacs_account->account_name,
                        ),
                        'account_number' => array(
                            'label' => __( 'Account number', 'woocommerce' ),
                            'value' => $bacs_account->account_number,
                        ),                    
                        'bank_name'      => array(
                            'label' => __( 'Nome Banco', 'woocommerce' ),
                            'value' => $bacs_account->bank_name,
                        ),
                        'bank_agency'      => array(
                            'label' => __( 'Agencia', 'woocommerce' ),
                            'value' => $bacs_account->bank_agency,
                        ),
                        'sort_code'      => array(
                            'label' => $sortcode,
                            'value' => $bacs_account->sort_code,
                        ),
                        'pid'           => array(
                            'label' => __( 'PID', 'woocommerce' ),
                            'value' => $bacs_account->pid,
                        ),
                        'iban'           => array(
                            'label' => __( 'IBAN', 'woocommerce' ),
                            'value' => $bacs_account->iban,
                        ),
                        'bic'            => array(
                            'label' => __( 'BIC', 'woocommerce' ),
                            'value' => $bacs_account->bic,
                        ),
                    ),
                    $order_id
                );


// define the woocommerce_bacs_account_fields callback 

function custom_woocommerce_bacs_account_fields( $array, value => $bacs_account_bank_name), account_number => array, value => $bacs_account_account_number), sort_code => array, iban => array, value => $bacs_account_iban), bic => array, value => $bacs_account_bic),pid => array, value => $bacs_account_pid)), $order_id ){ 
   //custom code here
    return $array, value => $bacs_account_bank_name), account_number => array, value => $bacs_account_account_number), sort_code => array, iban => array, value => $bacs_account_iban), bic => array, value => $bacs_account_bic), pid => array, value => $bacs_account_pid))
} 

//add the action 
add_filter('woocommerce_bacs_account_fields', 'custom_woocommerce_bacs_account_fields', 10, 2)

2

Answers


  1. Chosen as BEST ANSWER

    So, as i didn't get any clear help in this case, here is a clear solution that helped me.

    function newfield_bacs_account_field( $account_fields, $order_id ) {
        $account_fields['test_added' ] = array(
            'label' => __( 'labelfield', 'woocommerce' ),
             'value' => __( 'valuefield', 'woocommerce' ),
        );
        return $account_fields;
    }
    
    add_filter( 'woocommerce_bacs_account_fields', 'newfield_bacs_account_field', 10, 2);
    
    

  2. Anyone looking for adding multiple fields in bank details:

    add_filter( 'woocommerce_bacs_account_fields', 'bank_new_field_bacs_account_field', 10, 2);
    function bank_new_field_bacs_account_field( $account_fields, $order_id ) {
         $account_fields['bankadd0' ] = array(
            'label' => 'place',
             'value' => 'place value' 
        );
         $account_fields['bankadd' ] = array(
            'label' => 'LAND',
             'value' => 'land value' 
        );
        return $account_fields;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search