Skip to content

Instantly share code, notes, and snippets.

@jjmontalban
Created May 11, 2021 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjmontalban/e9537dd799222736553bcac874bdbaa8 to your computer and use it in GitHub Desktop.
Save jjmontalban/e9537dd799222736553bcac874bdbaa8 to your computer and use it in GitHub Desktop.
Add extra fields to Billing Form
<?php
/**
* @snippet Añadir nuevo campo al billing form
*/
add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
// Backend: Display editable custom billing fields
//add_filter( 'woocommerce_admin_billing_fields' , 'add_admin_custom_fields' );
function custom_woocommerce_billing_fields($fields)
{
$fields['billing_phone2'] = array(
'label' => __('Teléfono 2', 'woocommerce'), // Add custom field label
'placeholder' => _x('', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => true,
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('input-text'), // add class name
'description' => 'Teléfono alternativo',
);
$fields['billing_cif'] = array(
'label' => __('CIF/NIF', 'woocommerce'), // Add custom field label
'placeholder' => _x('', 'placeholder', 'woocommerce'), // Add custom field placeholder
'required' => true,
'clear' => false, // add clear or not
'type' => 'text', // add field type
'class' => array('input-text'), // add class name
'description' => 'Codigo Identificacion Fiscal',
);
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment