Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Created October 13, 2020 14:16
Show Gist options
  • Save hedqvist/fef438db0816337a327c29c00e9b570c to your computer and use it in GitHub Desktop.
Save hedqvist/fef438db0816337a327c29c00e9b570c to your computer and use it in GitHub Desktop.
Fortnox - Account Depending on VAT
<?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