Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter dlejongard

    (@dlejongard)

    UPDATE:

    Hi,
    If this can help:

    I have been doing some research, and realise that the woocommerce_email_order_meta_keys is deprecated. If you want to add the VAT number to the billing address we need to use the woocommerce_order_get_formatted_billing_address filter, like in the example below:

    Hope this can be helpful if another client has the same issue.

    add_filter( 'woocommerce_order_get_formatted_billing_address', function( $address, $raw_address, $order ) {
        if ( ! empty( $vat_number = $order->get_meta( '_billing_vat' ) ) ) {
            $address .= sprintf( '<br>%s: %s', __( 'VAT number', 'woocommerce' ), $vat_number );
        }
        return $address;
    }, 10, 3 );

    Best Regards
    D

    Thread Starter dlejongard

    (@dlejongard)

    I wouldn’t be able to confirm that. We gathered a php script for this job, we are more “designers” than “developers”, please see the script below (by the way, do you have a plugin that would do the job of this php script?):

    add_filter('woocommerce_billing_fields' , 'display_billing_vat_fields');
    function display_billing_vat_fields($billing_fields){
        $billing_fields['billing_vat'] = array(
            'type' => 'text',
            'label' =>  __('VAT number',  'woocommerce' ),
            'class' => array('form-row-wide'),
            'required' => false,
            'clear' => true,
            'priority' => 35, // To change the field location increase or decrease this value
        );
    
        return $billing_fields;
    }
    
    // Printing the Billing Address on My Account
    add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 10, 3 );
    function custom_my_account_my_address_formatted_address( $fields, $customer_id, $type ) {
    
        if ( $type == 'billing' ) {
            $fields['vat'] = get_user_meta( $customer_id, 'billing_vat', true );
        }
    
        return $fields;
    }
    
    // Checkout -- Order Received (printed after having completed checkout)
    add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_formatted_billing_address', 10, 2 );
    function custom_add_vat_formatted_billing_address( $fields, $order ) {
        $fields['vat'] = $order->get_meta('billing_vat');
    
        return $fields;
    }
    
    // Creating merger VAT variables for printing formatting
    add_filter( 'woocommerce_formatted_address_replacements', 'custom_formatted_address_replacements', 10, 2 );
    function custom_formatted_address_replacements( $replacements, $args  ) {
        $replacements['{vat}'] = ! empty($args['vat']) ? $args['vat'] : '';
        $replacements['{vat_upper}'] = ! empty($args['vat']) ? strtoupper($args['vat']) : '';
    
        return $replacements;
    }
    
    //Defining the Spanish formatting to print the address, including VAT.
    add_filter( 'woocommerce_localisation_address_formats', 'custom_localisation_address_format' );
    function custom_localisation_address_format( $formats ) {
        foreach($formats as $country => $string_address ) {
            $formats[$country] = str_replace('{company}\n', '{company}\n{vat_upper}\n', $string_address);
        }
        return $formats;
    }
    
    add_filter( 'woocommerce_customer_meta_fields', 'custom_customer_meta_fields' );
    function custom_customer_meta_fields( $fields ) {
        $fields['billing']['fields']['billing_vat'] = array(
            'label'       => __( 'VAT number', 'woocommerce' )
        );
    
        return $fields;
    }
    
    add_filter( 'woocommerce_admin_billing_fields', 'custom_admin_billing_fields' );
    function custom_admin_billing_fields( $fields ) {
        $fields['vat'] = array(
            'label' => __( 'VAT number', 'woocommerce' ),
            'show'  => true
        );
    
        return $fields;
    }
    
    add_filter( 'woocommerce_found_customer_details', 'custom_found_customer_details' );
    function custom_found_customer_details( $customer_data ) {
        $customer_data['billing_vat'] = get_user_meta( $_POST['user_id'], 'billing_vat', true );
    
        return $customer_data;
    }
    // VAT Number in emails
    add_filter( 'woocommerce_email_order_meta_keys', 
    'supine_vat_number_display_email' );
    
    function supine_vat_number_display_email( $keys ) {
     $keys['VAT Number'] = '_billing_vat';
     return $keys;
    }
    Thread Starter dlejongard

    (@dlejongard)

    Dear Alex,
    Yes, as I said, we are using a snippet to get and store clients’ VAT number in user account. We would like this VAT number to appear in the PDF invoice.

    Regards
    D

    Dear Mirza,
    Just accessed “Edit Order” from admin panel (where the error messages were), it seems that the error messages have disappeared. I will nevertheless monitor and visit other sections that may be related to ANU Plugin and send you an update if ever I see anything else.

    I thank you for your support.

    Best Regards
    Didier

    Hi,
    I am getting the same series of errors visible in the Admin Area under “Edit Order” :

    Notice: Function register_rest_route was called incorrectly. The REST API route definition for nua-zapier/v1/auth is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/grossistechasse/public_html/wp-includes/functions.php on line 5835
    
    Notice: Function register_rest_route was called incorrectly. The REST API route definition for nua-zapier/v1/user-approved is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/grossistechasse/public_html/wp-includes/functions.php on line 5835
    
    Notice: Function register_rest_route was called incorrectly. The REST API route definition for nua-zapier/v1/user-denied is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /home/grossistechasse/public_html/wp-includes/functions.php on line 5835

    I tried to follow the link above to download updated plugin but the file is no more there.

    I would be grateful if you could assit.

    Thanking you in advance

    Best Regards
    D

Viewing 5 replies - 1 through 5 (of 5 total)