Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created March 4, 2020 19:09
Show Gist options
  • Select an option

  • Save hedqvist/4c98cbb29db7a557157b5e4eb9229a86 to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/4c98cbb29db7a557157b5e4eb9229a86 to your computer and use it in GitHub Desktop.
Fortnox - Invoice Specials
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Set Terms and PaymentWay if Swish order
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.2
*/
function redlight_fortnox_payment_method_invoicetype($invoice, $order_id) {
$order = new WC_Order($order_id);
$order_payment_method = $order->get_payment_method();
switch( $order_payment_method ) {
case 'redlight_swish':
case 'redlight_swish-ecommerce':
$invoice['Invoice']['InvoiceType'] = 'CASHINVOICE';
$invoice['Invoice']['TermsOfPayment'] = '0';
$invoice['Invoice']['PaymentWay'] = 'SW';
break;
default:
$invoice['Invoice']['InvoiceType'] = 'INVOICE' ;
}
return $invoice;
}
add_filter('obj_fortnox_update_invoice_params', 'redlight_fortnox_payment_method_invoicetype', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment