Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created June 11, 2020 08:04
Show Gist options
  • Select an option

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

Select an option

Save hedqvist/da84fa4fdec6af55a59348249b8dc289 to your computer and use it in GitHub Desktop.
Fortnox - Only Bookeep orders that has Swish as Payment Method
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Bookeep only Swish Orders
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 4.2.0
*/
function redlight_fortnox_bookeep_swish($should_bookeep,$order_id, $updated_order) {
$order = wc_get_order($order_id);
$order_payment_method = $order->get_payment_method();
switch( $order_payment_method ) {
case 'redlight_swish':
case 'redlight_swish-ecommerce':
$should_bookeep = true;
break;
default:
$should_bookeep = false;
}
return $should_bookeep;
}
add_filter('obj_fortnox_create_order_bookeep_invoice', 'redlight_fortnox_bookeep_swish', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment