1

我正在为我的 woocmmerce 构建一个新的自定义文件,我找到了在 woocommerce 结帐中添加新文件的代码。

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>';
}

我想要的是你在上面找到这段代码

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

我想从下面的代码到上面获取我的动态值和选项

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

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
  }
    ?>

4

0 回答 0