I am running a WooCommerce v. 3 store and using a payment plugin "Quickpay". The payment plugin supports adding the transactions fee to the order which is great, but it is added without tax to the order i WooCommerce.
I have located the code where the transactions fee is set. I have tried digging through the documentation fra WC, but still can't figure it out.
Can any help me setting it up, so that tax is calculated for the transactions fee?
This is the current code:
/**
* add_transaction_fee function.
*
* Adds order transaction fee to the order before sending out the order confirmation
*
* @access public
*
* @param $fee_amount
*
* @return bool
*/
public function add_transaction_fee($fee_amount)
{
if ($fee_amount > 0) {
$amount = $fee_amount / 100;
$fee = (object) array(
'name' => __('Payment Fee', 'woo-quickpay'),
'amount' => wc_format_decimal($amount),
'taxable' => FALSE,
'tax_class' => NULL,
'tax_data' => array(),
'tax' => 0,
);
if (version_compare( WC_VERSION, '3.0', '<' )) {
$this->add_fee($fee);
} else {
$item = new WC_Order_Item_Fee();
$item->set_props( array(
'name' => $fee->name,
'tax_class' => $fee->tax_class,
'total' => $amount,
'total_tax' => 0,
'order_id' => $this->get_id(),
) );
$item->save();
$this->add_item( $item );
}
$this->set_total( $this->get_total() + $amount );
return TRUE;
}
return FALSE;
}