Created
October 13, 2020 14:16
-
-
Save hedqvist/fef438db0816337a327c29c00e9b570c to your computer and use it in GitHub Desktop.
Fortnox - Account Depending on VAT
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 - Set Accountnumber depending on VAT | |
* @author Redlight Media AB / Christopher Hedqvist | |
* @compatible WooCommerce 4.6.0 | |
*/ | |
function redlight_fortnox_account_based_on_vat($orderData) { | |
foreach($orderData['Order']['OrderRows'] as $i => $item) { | |
if( $item['VAT'] == 25 ){ | |
$orderData['Order']['OrderRows'][$i]['AccountNumber'] = 3001; | |
} | |
if( $item['VAT'] == 12 ){ | |
$orderData['Order']['OrderRows'][$i]['AccountNumber'] = 3002; | |
} | |
if( $item['VAT'] == 6 ){ | |
$orderData['Order']['OrderRows'][$i]['AccountNumber'] = 3003; | |
} | |
} | |
return $orderData; | |
} | |
add_filter('obj_fortnox_order_data', 'redlight_fortnox_account_based_on_vat', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment