Last active
May 14, 2019 18:06
-
-
Save webdados/88c5a425ba2fcb88671c6fa93ad3154e to your computer and use it in GitHub Desktop.
Payment method on InvoiceXpress document observations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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