Skip to content

Instantly share code, notes, and snippets.

@webdados
Last active June 1, 2024 08:58
Show Gist options
  • 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 (sku)
$item_data['name'] = 'whatever';
// Or add something to its description (product title)
$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