2014-12-24 58 views
1

我加入了一些自定義字段到我的結賬頁面,用下面的代碼添加描述:WooCommerce - woocommerce_form_field()之前結賬

add_action('woocommerce_before_order_notes', 'bs_custom_checkout_fields'); 
function bs_custom_checkout_fields($checkout) { 

    woocommerce_form_field('order_domain_name', array(
     'type'   => 'text', 
     'class'   => array('my-field-class form-row-wide'), 
     'label'   => __('Name','bs'), 
     'placeholder' => __('Enter the name','bs'), 
     'required'  => true, 
    ), $checkout->get_value('order_domain_name')); 
} 

我需要這個領域之前添加一些額外的說明,解釋用戶該字段意味着什麼。有沒有辦法做到這一點?

感謝

回答

0

使用description參數:

add_action('woocommerce_before_order_notes', 'bs_custom_checkout_fields'); 
function bs_custom_checkout_fields($checkout) { 

woocommerce_form_field('order_domain_name', array(
    'type'   => 'text', 
    'class'   => array('my-field-class form-row-wide'), 
    'label'   => __('Name','bs'), 
    'placeholder' => __('Enter the name','bs'), 
    'required'  => true, 
    'description => __('Additional description goes here','bs') 
), $checkout->get_value('order_domain_name')); 

}

+0

謝謝,這幾乎成功,唯一的問題是它添加了描述後的領域...任何機會把它放在領域之前?我目前正在使用jQuery,但更喜歡一些nonJS解決方案.. – user1049961

0

這是在回答把描述標籤下方。

您需要破解/plugins/woocommerce/includes/wc-template-functions.php

招行2103 - $field_html .= $field; 到2108線

這是你能做的一切,而不是WooCommerce不幸的是更新的證明。