Last active
April 9, 2023 13:14
-
-
Save hedqvist/6fcafb0018eecb50bd684310066f50b6 to your computer and use it in GitHub Desktop.
Fortnox AdministrativeFee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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