Skip to content

Instantly share code, notes, and snippets.

@dennisnissle
Created August 5, 2025 08:00
Show Gist options
  • Select an option

  • Save dennisnissle/879ba74229ece962a9d1e351bba77b4c to your computer and use it in GitHub Desktop.

Select an option

Save dennisnissle/879ba74229ece962a9d1e351bba77b4c to your computer and use it in GitHub Desktop.
Adjust journal type when syncing invoice
<?php
add_action( 'storeabill_woo_order_synced_invoice', function( $invoice, $sab_order ) {
$woo_order = $sab_order->get_order();
// Check products and determine whether to use a custom journal type
$condition = false;
if ( $condition ) {
$custom_journal_type = 'custom_invoice';
if ( ! $journal = sab_get_journal( $custom_journal_type ) ) {
sab_create_journal( $custom_journal_type );
}
$invoice->set_journal_type( $custom_journal_type );
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment