Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Created April 29, 2020 22:34
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 vfontjr/306a0950811322e4810eb5be7a24af26 to your computer and use it in GitHub Desktop.
Save vfontjr/306a0950811322e4810eb5be7a24af26 to your computer and use it in GitHub Desktop.
<?php
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_company']['label'] = 'Clinic Name';
$fields['shipping']['shipping_company']['label'] = 'Clinic Name';
$fields['billing']['billing_first_name']['label'] = 'Physician First Name';
$fields['billing']['billing_last_name']['label'] = 'Physician Last Name';
$fields['shipping']['shipping_first_name']['label'] = 'Physician First Name';
$fields['shipping']['shipping_last_name']['label'] = 'Physician Last Name';
$fields['billing']['dea_number'] = array(
'label' => __('DEA Number', 'woocommerce'),
'placeholder' => _x('If you are already registered, make sure to use your approved DEA Number', 'placeholder', 'woocommerce'),
'required' => true,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
/**
* Display field value on the order edition page
**/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo __('DEA Number'). ': ' . $order->order_custom_fields['_dea_number'][0];
}
<?php
/**
* Display field value on the order edition page
**/
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta($order){
echo __('DEA Number').': ' . $order->dea_number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment