Ich erhalte diesen Code, um dem WooCommerce-Abrechnungsformular ein benutzerdefiniertes Feld hinzuzufügen.
Das Feld wird angezeigt, aber das Problem ist, dass das Feld nicht angezeigt wird label
Noch placeholder
Noch class name
.
Was fehlt mir hier? Ich habe diesen Code zu functions.php in meinem Child-Theme hinzugefügt.
/*******************************
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;
}
Wenn Sie verwenden woocommerce_billing_fields
Dann müssen Sie die Felder nicht angeben, sie werden automatisch den Abrechnungsfeldern zugewiesen. Aber wenn Sie verwenden woocommerce_checkout_fields
dann müssen Sie nur angeben, dass Sie ein Feld für möchten shipping
oder billing
.
Zum woocommerce_billing_fields
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields)
{
$fields['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;
}
Zum woocommerce_checkout_fields
add_filter('woocommerce_checkout_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;
}
Bezug:
Sie können Ihren Code für das Custombilling-Feld zum hinzufügen
get_default_address_fields()
Funktion in derclass-wc-countries.php
Datei– Daniel_ZA
20. Februar 2017 um 10:29 Uhr