2014-04-24 3 views
-2

주문을 처리하는 데 필요한 추가 데이터를 수집하는 체크 아웃 양식 끝에 맞춤 필드를 추가하려고합니다.WooCommerce 체크 아웃을위한 주문 노트 후에 선택 필드 추가하기

이 내가 무엇을 가지고 :

add_action('woocommerce_after_order_notes', 'student_info_fields'); 

function student_info_fields($checkout) { 

    echo '<div id="student_info"><span>The following information below will be used to create an account.</span>'; 

    //This adds a student_name field 
    woocommerce_form_field('student_name', array(
     'type'  => 'text', 
     'class'  => array('form-row-wide'), 
     'label'  => __('Student Name'), 
     'placeholder' => __('eg: "John Smith", "Johnny", etc'), 
     'required' => 'true', 
    ), $checkout->get_value('student_name')); 

    /* I have two other text fields here that follow the same syntax as student_name */ 

    //This adds a student_gender field 
    woocommerce_form_field('student_gender', array(
     'type'  => 'select', 
     'label'  => __('Gender', 'woocommerce'), 
     'placeholder' => _x('', 'placeholder', 'woocommerce'), 
     'required' => 'true', 
     'options'  => array(
      'male' => __('Male', 'woocommerce'), 
      'female' => __('Female', 'woocommerce') 
     ), 
    ), $checkout->get_value('student_gender')); 

    echo '</div>'; 

} 

가 텍스트 필드 모두 작동하는 것,하지만 난 student_gender 필드를 추가, 내 페이지 나누기 (모든 흰색 화면). 나는 student_gender 배열 내에서 options 배열을 호출하고 각 필드를 선언 한 후에 $checkout ->get_value... 행을 호출하는 것으로 약간 계획을 세웠지 만, 나는 단지 무엇을해야할지 모르겠다.

나에게 줄 수있는 방향은이 너트를 부수는 데 도움이 될 것입니다. 고집 주셔서 감사합니다!

+0

봐 :

나는 내 코드를 변경했습니다. 아마도 이것은 필요한 모든 정보를 제공 할 것입니다. 그렇지 않은 경우 다시 돌아와 질문에 오류를 붙여 넣으십시오. –

답변

1

나는 그것을보고 무엇이 엉망인지 알아 냈습니다. 말하자면, 올바른 구문을 사용하지 않았다고 선언 한 내 label 선언을 지적했습니다. 정확한 오류를 알고 서버의 오류 로그에

//This adds a student_gender field 
woocommerce_form_field('student_gender', array(
    'type'  => 'select', 
    'label'  => __('Student Gender'), 
    'placeholder' => _x('', 'placeholder', 'woocommerce'), 
    'required' => 'true', 
    'options'  => array(
      'male' => __('Male', 'woocommerce'), 
      'female' => __('Female', 'woocommerce') 
    ), 
), $checkout->get_value('student_grade')); 
관련 문제