Skip to content

Instantly share code, notes, and snippets.

@dennisnissle
Created February 28, 2024 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennisnissle/5c754102e75469bdcdd22682084176f5 to your computer and use it in GitHub Desktop.
Save dennisnissle/5c754102e75469bdcdd22682084176f5 to your computer and use it in GitHub Desktop.
Use a different invoice template based on country
<?php
add_filter( 'storeabill_invoice_get_template', function( $template, $invoice ) {
$country = $invoice->get_taxable_country();
$template_id = false;
if ( 'AT' === $country ) {
$template_id = 320;
} elseif ( $invoice->is_eu() ) {
$template_id = 323;
} elseif ( $invoice->is_third_country() ) {
$template_id = 325;
}
if ( $template_id ) {
if ( $template = sab_get_document_template( $template_id ) ) {
return $template;
}
}
return $template;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment