Skip to content

Instantly share code, notes, and snippets.

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 webdados/88c5a425ba2fcb88671c6fa93ad3154e to your computer and use it in GitHub Desktop.
Save webdados/88c5a425ba2fcb88671c6fa93ad3154e to your computer and use it in GitHub Desktop.
Payment method on InvoiceXpress document observations
<?php
// This code snippet is to be used with the "Invoicing with InvoiceXpress for WooCommerce" plugin - https://invoicexpress-woocommerce.com/
$types = array(
'invoice',
'simplified_invoice',
'invoice_receipt',
'credit_note',
'quote',
'proforma',
'transport_guide',
'devolution_guide',
);
foreach ( $types as $type ) {
add_filter( "invoicexpress_woocommerce_{$type}_data", 'my_woocommerce_ixpro_payment_method_obs_filter', 10, 2 );
}
function my_woocommerce_ixpro_payment_method_obs_filter( $document_data, $order_object ) {
if ( $method = $order_object->get_payment_method_title() ) {
$observations = explode( PHP_EOL, trim( $document_data['observations'] ) );
$observations[] = 'Payment method: '.trim( $method );
$document_data['observations'] = implode( PHP_EOL, array_filter( $observations, function( $value ) { return trim( $value ) !== ''; } ) );
}
return $document_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment