Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active February 7, 2022 10:29
Show Gist options
  • Select an option

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

Select an option

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