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
Created November 6, 2023 09:24
Attach invoice to completed mail
<?php
add_filter( 'storeabill_woo_attach_invoice_to_email', function( $attach, $email_id ) {
if ( 'customer_completed_order' === $email_id ) {
$attach = true;
}
return $attach;
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Created October 24, 2023 11:01
Disable Germanized checkout block adjustments
<?php
add_filter( 'woocommerce_gzd_disable_checkout_block_adjustments', '__return_true' );
@dennisnissle
dennisnissle / functions.php
Created August 15, 2023 12:06
Pass PW gift card number to invoice voucher item name
<?php
add_filter( 'storeabill_woo_order_forced_discount_notice', function( $discount_notice, $discount, $last_invoice, $sab_order ) {
$discount = sab_format_decimal( $discount, '' );
foreach( $sab_order->get_order()->get_items( 'pw_gift_card' ) as $line ) {
$amount = sab_format_decimal( $line->get_amount(), '' );
$pw_card_number = $line->get_card_number();
if ( $amount === $discount ) {
@dennisnissle
dennisnissle / functions.php
Created July 25, 2023 13:03
Disable invoice auto sync for a certain product id
<?php
add_filter( 'storeabill_woo_auto_sync_order_invoices', function( $enable_auto_sync, $order_id ) {
$my_product_id = 123;
if ( $order = wc_get_order( $order_id ) ) {
$product_ids = array();
foreach( $order->get_items( 'line_item' ) as $item ) {
$product_ids[] = $item->get_product_id();
}
@dennisnissle
dennisnissle / functions.php
Created July 10, 2023 14:40
Skip deposit calculation for non-domestic orders
<?php
add_filter( 'woocommerce_gzd_shipping_country_skips_deposit', function( $skips_deposit, $country ) {
if ( 'DE' !== $country ) {
$skips_deposit = true;
}
return $skips_deposit;
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Created June 14, 2023 09:04
Do not add placeholder for Stripe in case of manual order confirmation
<?php
add_filter( 'woocommerce_gzdp_manual_contract_gateway_needs_placeholder', function( $needs_placeholder, $method ) {
if ( 'stripe' === $method ) {
$needs_placeholder = false;
}
return $needs_placeholder;
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Last active May 30, 2023 08:48
Attach PDF invoice to customer completed mail
<?php
add_filter( 'storeabill_woo_attach_invoice_to_email', function( $attach_to_mail, $email_id ) {
if ( 'customer_completed_order' === $email_id ) {
$attach_to_mail = true;
}
return $attach_to_mail;
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Created May 15, 2023 09:00
Decrease legal text font size in emails
<?php
add_filter( 'woocommerce_email_styles', function( $css ) {
$css .= '.wc-gzd-email-attach-post { font-size: 11px; }';
return $css;
} );
@dennisnissle
dennisnissle / functions.php
Created April 20, 2023 12:42
Use formatted order number as girocode subject
<?php
add_filter( 'storeabill_invoice_girocode_subject', function( $subject, $invoice ) {
return $invoice->get_order_number();
}, 10, 2 );
@dennisnissle
dennisnissle / functions.php
Created April 20, 2023 09:47
Adjust sevDesk category ID based on base country, EU, third country
<?php
add_filter( 'storeabill_external_sync_sevdesk_item_category_id', function ( $category_id, $item, $invoice ) {
if ( $invoice->is_third_country() ) {
// Third country category id
$category_id = 33;
if ( 'cancellation' === $invoice->get_invoice_type() ) {
// Third country category id for cancellations
$category_id = 34;