Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created October 31, 2014 22:44
Show Gist options
  • Select an option

  • Save dancameron/8abd701c85a85a5c6628 to your computer and use it in GitHub Desktop.

Select an option

Save dancameron/8abd701c85a85a5c6628 to your computer and use it in GitHub Desktop.
Client Meta Addon

How to add VAT to you invoices and estimates

/**
 * Adds the VAT below the company name on the estimates and invoices via a hook
 * that was added in version 1.1.4 of Sprout Invoices.
 */
function si_maybe_add_vat_to_docs() {
	$client_id = 0;
	$doc_id = get_the_id();
	if ( get_post_type( $doc_id ) == SI_Invoice::POST_TYPE ) {
		$client_id = si_get_invoice_client_id();
	}
	if ( get_post_type( $doc_id ) == SI_Estimate::POST_TYPE ) {
		$client_id = si_get_estimate_client_id();
	}
	if ( $client_id ) {
		$client = SI_Client::get_instance( $client_id );
		printf( self::__('<em>VAT: %s</em>'), self::get_vat( $client ) );
	}
}
add_action( 'si_document_client_addy', 'si_maybe_add_vat_to_docs' );

If you're not running the latest version of Sprout Invoices or you don't like the location of the meta in the example above you can create a custom template and add the VAT yourself.

The function to get the value si_get_client_vat. The function to echo the value si_client_vat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment