Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active April 9, 2023 13:14
Show Gist options
  • Save hedqvist/6fcafb0018eecb50bd684310066f50b6 to your computer and use it in GitHub Desktop.
Save hedqvist/6fcafb0018eecb50bd684310066f50b6 to your computer and use it in GitHub Desktop.
Fortnox AdministrativeFee
<?php
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Add fee to AdministrativeFee via functions.php
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.2.5
*/
function redlight_fortnox_administrative_fee( $orderData, $order_id ) {
// Get the total fees of this order
$order = wc_get_order($order_id);
$fees = $order->get_fees();
$total_fees = 0;
foreach( $fees as $fee ){
$total_fees += $fee->get_total();
}
$orderData['Order']['AdministrationFee'] = $total_fees;
return $orderData;
}
add_filter('obj_fortnox_order_data', 'redlight_fortnox_administrative_fee', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment