Last active
June 16, 2020 20:57
-
-
Save estebandelaf/acd77824a922de244f933f47403b4079 to your computer and use it in GitHub Desktop.
Snippet para solicitar datos de un DTE chileno en el checkout de WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields'); | |
function custom_override_checkout_fields($fields) | |
{ | |
$fields['billing']['billing_documento'] = array( | |
'type' => 'select', | |
'label' => __('Documento', 'woocommerce'), | |
'options' => array(33=>'Factura', 39=>'Boleta'), | |
'required' => true, | |
'class' => array('form-row-wide'), | |
'clear' => true, | |
); | |
$fields['billing']['billing_rut'] = array( | |
'label' => __('RUT', 'woocommerce'), | |
'required' => true, | |
'class' => array('form-row-wide'), | |
'clear' => true, | |
); | |
$fields['billing']['billing_giro'] = array( | |
'label' => __('Giro', 'woocommerce'), | |
'required' => false, | |
'class' => array('form-row-wide'), | |
'clear' => true, | |
); | |
return $fields; | |
} | |
add_action('woocommerce_admin_order_data_after_shipping_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1); | |
function my_custom_checkout_field_display_admin_order_meta($order) | |
{ | |
$documentos = [33=>'Factura', 39=>'Boleta']; | |
echo '<h3>Datos DTE</h3>'; | |
echo '<p><strong>'.__('Documento').':</strong><br/>'.$documentos[get_post_meta($order->get_id(), '_billing_documento', true)].'</p>'; | |
echo '<p><strong>'.__('RUT').':</strong><br/>'.get_post_meta($order->get_id(), '_billing_rut', true).'</p>'; | |
echo '<p><strong>'.__('Giro').':</strong><br/>'.get_post_meta($order->get_id(), '_billing_giro', true).'</p>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment