Skip to content

Instantly share code, notes, and snippets.

View dennisnissle's full-sized avatar

Dennis Nissle dennisnissle

View GitHub Profile
@dennisnissle
dennisnissle / functions.php
Last active November 28, 2025 10:48
Add invoice data to WC Order Export Lite https://de.wordpress.org/plugins/woo-order-export-lite/
<?php
add_filter( 'woe_get_order_fields', 'my_child_add_order_export_data' );
function my_child_add_order_export_data( $fields ) {
$fields['invoice_numbers'] = array( 'label' => 'Invoice Numbers', 'colname' => 'Invoice Numbers', 'checked' => 1 );
return $fields;
}
@dennisnissle
dennisnissle / functions.php
Created November 28, 2025 08:44
Use a different invoice template for orders with company field
<?php
add_filter( 'storeabill_invoice_get_template', function( $template, $invoice ) {
$template_id = false;
if ( ! empty( $invoice->get_company() ) ) {
$template_id = 320; // Post id of the template to be used
}
if ( $template_id ) {
@dennisnissle
dennisnissle / functions.php
Created November 4, 2025 10:15
Send paid for order mail for invoice gateway too
<?php
add_filter( 'woocommerce_gzd_disable_gateways_paid_order_email', function( $gateways ) {
$gateways = array_diff( $gateways, array( 'invoice' ) );
return $gateways;
} );
@dennisnissle
dennisnissle / functions.php
Created September 16, 2025 07:45
Send invoice to admin on order status pending to processing
<?php
add_action( 'woocommerce_order_status_pending_to_processing_notification', function( $order_id ) {
if ( $order = sab_get_order( $order_id ) ) {
if ( $invoice = $order->get_latest_finalized_invoice() ) {
$invoice->send_to_admin();
}
}
}, 10 );
@dennisnissle
dennisnissle / functions.php
Created August 15, 2025 07:19
Adjust invoice email address
<?php
add_filter( 'storeabill_woo_order_email', function( $billing_email, $invoice_order ) {
$wc_order = $invoice_order->get_order();
return $billing_email;
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Last active August 5, 2025 08:02
Adjust DHL label customer reference
<?php
add_filter( 'woocommerce_stc_dhl_label_customer_reference', 'my_child_adjust_dhl_customer_reference', 10, 3 );
function my_child_adjust_dhl_customer_reference( $ref, $label, $shipment ) {
$ref = $shipment->get_order_number();
return $ref;
}
@dennisnissle
dennisnissle / functions.php
Created August 5, 2025 08:00
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';
@dennisnissle
dennisnissle / functions.php
Last active August 1, 2025 14:02
Do not create shipments if cash on delivery was selected as shipping method
<?php
add_filter( 'woocommerce_shiptastic_shipment_order_needs_shipping', 'my_child_check_if_order_needs_shipping', 10, 3 );
function my_child_check_if_order_needs_shipping( $needs_shipping, $order, $order_shipment ) {
foreach ( $order->get_shipping_methods() as $shipping_method ) {
if ( 'cod' === $shipping_method->get_method_id() ) {
$needs_shipping = false;
break;
}
@dennisnissle
dennisnissle / functions.php
Last active July 31, 2025 06:57
Add a new column to the shipment table (e.g. output the order status)
<?php
add_filter( 'woocommerce_shiptastic_shipments_table_columns', 'my_child_add_shipment_columns', 10 );
function my_child_add_shipment_columns( $columns ) {
$columns['order_status'] = 'Order status';
return $columns;
}
add_filter( 'woocommerce_shiptastic_shipments_table_custom_column', 'my_child_shipment_order_status_column', 10, 2 );
@dennisnissle
dennisnissle / functions.php
Last active July 31, 2025 06:56
Register a custom shipment status
<?php
add_filter( 'woocommerce_shiptastic_shipment_statuses', function( $statuses ) {
$statuses['custom-status'] = 'My custom status';
return $statuses;
} );