• Resolved fadipet

    (@fadipet)


    Hi,
    Is it possible to hide or remove billing first name and billing last name from Invoice when our customer enters his Company name?
    Please help me

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    This is a bit tricky because the address is provided to our plugin ‘as-is’ (fully formatted) by WooCommerce… You may be able to get the desired result with the following code snippet:

    
    add_filter( 'wpo_wcpdf_billing_address', 'wpo_wcpdf_address_company_name', 10, 2 );
    add_filter( 'wpo_wcpdf_shipping_address', 'wpo_wcpdf_address_company_name', 10, 2 );
    function wpo_wcpdf_address_company_name( $address, $document ) {
    	if ( !empty($document->order) ) {
    		$address_type = str_replace( array( 'wpo_wcpdf_', '_address'), '', current_filter() );
    		$full_name = $document->order->{"get_formatted_".$address_type."_full_name"}();
    		$company = $document->order->{"get_".$address_type."_company"}();
    		if (!empty($company)) {
    			$address = str_replace( array( $full_name."<br>", $full_name."<br/>", $full_name ), '', $address);
    		}
    	}
    	return $address;
    }
    

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

    Hope that helps!

    Thread Starter fadipet

    (@fadipet)

    It works. Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove billing first name and last name when company name is not empty’ is closed to new replies.