Custom VAT number field – email's and checkout

This topic has 4 replies, 3 voices, and was last updated 6 years, 11 months ago ago by Rose Tyler

  • Avatar: wizualnemedia_pl
    wizualnemedia_pl
    Participant
    January 16, 2018 at 19:57

    Hello 🙂
    In the child theme I added custom VAT number field. This custom field is show in oredered e-mail but in not that way i like. Is anybody knows how to change location on oredered e-mail after company name in billing section (like on print screen) and also in checkout page?

    Print screen’s:
    E-mails: https://prnt.sc/i1bzkg
    Checkout: http://prntscr.com/i1c92s

    Code in child theme:
    #################################################################################################
    /**
    * START NIP
    */
    add_action( ‘woocommerce_after_checkout_billing_form’, ‘wizualne_vat_field’ );

    /**add_action( ‘woocommerce_after_checkout_shipping_form’, ‘wizualne_vat_field’ ); */

    /**
    * Pole NIP w zamówieniu
    */
    function wizualne_vat_field( $checkout ) {
    /** echo ‘<div id=”wizualne_vat_field”><h3 class=”step-title”><span>’ . __(‘Dane do Faktury’) . ‘</span></h3>’; */

    woocommerce_form_field( ‘vat_number’, array(
    ‘type’ => ‘text’,
    ‘class’ => array( ‘vat-number-field form-row-wide’) ,
    ‘label’ => __( ‘NIP’ ),
    ‘placeholder’ => __( ‘Wpisz NIP, aby otrzymać fakturę’ ),
    ), $checkout->get_value( ‘vat_number’ ));

    /** echo ‘</div>’; */
    }

    // Do NOT include the opening php tag shown above. Copy the code shown below.
    add_action( ‘woocommerce_checkout_update_order_meta’, ‘wizualne_checkout_vat_number_update_order_meta’ );
    /**
    * Save VAT Number in the order meta
    */
    function wizualne_checkout_vat_number_update_order_meta( $order_id ) {
    if ( ! empty( $_POST[‘vat_number’] ) ) {
    update_post_meta( $order_id, ‘_vat_number’, sanitize_text_field( $_POST[‘vat_number’] ) );
    }
    }

    add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘wizualne_vat_number_display_admin_order_meta’, 10, 1 );
    /**
    * Wyświetlenie pola NIP
    */
    function wizualne_vat_number_display_admin_order_meta( $order ) {
    echo ‘<p>‘ . __( ‘NIP’, ‘woocommerce’ ) . ‘: ‘ . get_post_meta( $order->id, ‘_vat_number’, true ) . ‘</p>’;
    }

    add_filter( ‘woocommerce_email_order_meta_keys’, ‘wizualne_vat_number_display_email’ );
    /**
    * Pole NIP w mailu
    */
    function wizualne_vat_number_display_email( $keys ) {
    $keys[‘NIP’] = ‘_vat_number’;
    return $keys;
    }
    /**
    * KONIEC NIP
    */
    #################################################################################################

    Thank you for your support 😉

    3 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    January 17, 2018 at 15:31

    Hello,

    We are sorry but we are unable to provide support for customizations under our Support Policy.

    You may check https://ru.wordpress.org/plugins/woocommerce-checkout-manager/ plugin if you need to make changes on the checkout page and check this article to find out how you can edit email templates https://www.cloudways.com/blog/how-to-customize-woocommerce-order-emails/

    Contact WPKraken team if you need help with customization.

    Regards

    Avatar: wizualnemedia_pl
    wizualnemedia_pl
    Participant
    January 18, 2018 at 19:47

    Ok, thank you Olga 😉

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    January 19, 2018 at 07:43

    Hello,

    You’re welcome!
    Have a nice day.

    Regards

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.