Add new filed in woocommerce checkout

I am building a new custom filed to my woocmmerce, I found the code which add new filed in woocommerce checkout.

add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');

function my_custom_checkout_field( $checkout ) {

    echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';

    woocommerce_form_field( 'my_field_name', array(
        'type'        => 'select',
        'class'       => array('my-field-class form-row-wide'),
        'required'    => true,
        'label'       => __('Fill in this field'),
        'placeholder' => __('Enter something'),
        'options'     => array(
        'choice1'     => __('choice1', 'woocommerce' ),
        'choice2'     => __('choice2', 'woocommerce' )
        )
    ), $checkout->get_value( 'my_field_name' ));

    echo '</div>';
}

What I want is you find this code above

Read More
'options'     => array(
    'choice1' => __('choice1', 'woocommerce' ),
    'choice2' => __('choice2', 'woocommerce' )
    )

I want to get my dynamic values and option from below code to above

option = <?php echo $software->name?>

and

value="<?php echo $software->id?>|<?php echo $tt*$total/100;?>|<?php echo $software->name?>|<?php echo $software->email?>"

 <select name="dropdown" class="select" id="dropdown">
      <option>Select-name</option>

    <?php
      $table = bor_get_software();
      if($table){
       $i=0;
       foreach($table as $software) { 
           $i++;
    ?>

          <?php $tt=$software->percentage;?>
            <?php $ter=($tt *100);?>
     <option value="<?php echo $software->id?>|<?php echo $tt*$total/100;?>|<?php echo $software->name?>|<?php echo $software->email?>" ><?php echo $software->name?></option>

    <?php
       }
    }
    else{   
  ?>

    <?php
  }
    ?>

Related posts

Leave a Reply