• Resolved Eu

    (@eupopescu)


    Hi there,

    Thank you for your hard work on this plugin.

    Before to post this question, I made a search without to find an answer.
    At this moment the invoice display the Woo billing form content without the labels (Company, Name, etc). Is there any setting I am missing? Or need to use some snippet to add the labels?

    Thank you for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @eupopescu,

    There is not a setting for this in our plugin. Although, since we use the formatted billing address, provided by WooCommerce, you could filter it, like this:

    /**
     * Add a label before some of the billing address properties
     */
    add_filter( 'woocommerce_order_formatted_billing_address', function( $billing_address, $order ) {
    	foreach ( $billing_address as $prop_key => $prop_value ){
    		if ( ! empty( $prop_value ) ) {
    			switch ( $prop_key ) {
    				case 'company':
    					$billing_address[$prop_key] = 'Company: ' . $prop_value;
    					break;
    				case 'first_name':
    					$billing_address[$prop_key] = 'Name: ' . $prop_value;
    					break;
    				case 'address_1':
    					$billing_address[$prop_key] = 'Address: ' . $prop_value;
    					break;
    			}
    		}
    	}
    	return $billing_address;
    }, 10, 2 );

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

    These are the available keys that you can use:

    • first_name
    • last_name
    • company
    • address_1
    • address_2
    • city
    • state
    • postcode
    • country
    • email
    • phone

    Let me know if it worked for you!

    Thread Starter Eu

    (@eupopescu)

    Yes, it is what I needed. Thank you very much! ??

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to hear that it worked for you!

    By the way, although we don’t have a specific setting to do this, as I mentioned above, I have realized that you can also achieve the same, with no code, within the Address customization, included in the Professional extension, this way:

    A screenshot that displays the billing address box, withing the Address Customization area, with a custom address pattern, including the field labels using the available placeholders

    Thread Starter Eu

    (@eupopescu)

    thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add field label to the invoice’ is closed to new replies.