Skip to content

Instantly share code, notes, and snippets.

@webdados
Last active December 31, 2023 11:53
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/830370772757a40062ee28565c81df64 to your computer and use it in GitHub Desktop.
Save webdados/830370772757a40062ee28565c81df64 to your computer and use it in GitHub Desktop.
Manipulate item data before adding it to a InvoiceXpress document on the "Invoicing with InvoiceXpress for WooCommerce – Pro" plugin
<?php
// Change item properties
add_filter( 'invoicexpress_woocommerce_document_item', function( $item_data, $item, $product, $order_object, $document_type, $args ) {
// Do whatever you want with the $item_data array, for example, change its reference or description
$item_data['name'] = 'whatever';
/ /Or add somthing to its description
$item_data['description'] .= 'whatever';
// And return it
return $item_data;
}, 10, 6 );
// Remove item from the document
add_filter( 'invoicexpress_woocommerce_document_item', function( $item_data, $item, $product, $order_object, $document_type, $args ) {
if ( $your_condition ) {
return false;
}
return $item_data;
}, 10, 6 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment