• Resolved jesussiero

    (@jesussiero)


    Hi everyone,

    i have try for 2 hours to show the VAT number in invoices.

    I have configurated properly the code in functions.php of my theme Divi but it does not appear.

    Thanks you in advance, this is really important for my company.

    ([email protected] for any question)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bas Elbers

    (@baaaaas)

    Hi,

    Provide us with the code you are using and what you are trying to add to the template.

    Thread Starter jesussiero

    (@jesussiero)

    Hi Bas, we are using VAT Number (NIF) without problems. Customer can introduce in the form order but the NIF does not appear in invoice.

    functions.php (Divi theme)
    add_action( ‘woocommerce_after_order_notes’, ‘agrega_mi_campo_personalizado’ );
    function agrega_mi_campo_personalizado( $checkout ) {
    echo ‘<div id=”additional_checkout_field”>’;
    woocommerce_form_field( ‘nif’, array(
    ‘type’ => ‘text’,
    ‘class’ => array(‘my-field-class form-row-wide’),
    ‘label’ => __(‘NIF-DNI <abbr class=”required” title=”obligatorio”>*</abbr>’),
    ‘required’ => false,
    ‘placeholder’ => __(‘Introduzca el No NIF-DNI’),
    ), $checkout->get_value( ‘nif’ ));
    echo ‘</div>’;

    add_action(‘woocommerce_checkout_process’, ‘comprobar_campo_nif’);

    function comprobar_campo_nif() {
    if ( ! $_POST[‘nif’] )
    wc_add_notice( __( ‘NIF-DNI, es un campo requerido. Debe de introducir su NIF DNI para finalizar la compra.’ ), ‘error’ );
    }

    add_action( ‘woocommerce_checkout_update_order_meta’, ‘actualizar_info_pedido_con_nuevo_campo’ );

    function actualizar_info_pedido_con_nuevo_campo( $order_id ) {
    if ( ! empty( $_POST[‘nif’] ) ) {
    update_post_meta( $order_id, ‘NIF’, sanitize_text_field( $_POST[‘nif’] ) );
    }
    }

    add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘mostrar_campo_personalizado_en_admin_pedido’, 10, 1 );

    function mostrar_campo_personalizado_en_admin_pedido($order){
    echo ‘<p>‘.__(‘NIF’).’: ‘ . get_post_meta( $order->id, ‘NIF’, true ) . ‘</p>’;
    }

    add_filter(‘woocommerce_email_order_meta_keys’, ‘muestra_campo_personalizado_email’);

    function muestra_campo_personalizado_email( $keys ) {
    $keys[] = ‘NIF’;
    return $keys;
    }

    Plugin Author Bas Elbers

    (@baaaaas)

    echo get_post_meta( $this->order->id, 'NIF', true );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Spanish VAT Number’ is closed to new replies.