我得到此代碼以將自定義字段添加到WooCommerce Billing表單。將自定義字段添加到WooCommerce結算表單中?
該字段被示出,但問題是該字段具有不label
也不placeholder
也不class name
。
我在這裏錯過了什麼? 我將這段代碼添加到我的子主題的functions.php中。
/*******************************
CUSTOM BILLING FIELD
******************************** */
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['billing']['billing_options'] = array(
'label' => __('NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('Your NIF here....', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => false, // if field is required or not
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('my-css') // add class name
);
return $fields;
}
您可以將custombilling字段的代碼添加到'class-wc-countries.php'文件中的'get_default_address_fields()'函數 –