Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Do not cross post topics and do not use Developing with WordPress for plugin specific asks. Duplicates are removed when found and I have removed yours.
I am unable to open your Gist link as it seems to be invalid. But to add in order to refund shipping and taxes you will have to make it part of the line_items array you pass to the wc_create_refund function.
Have a look at the the wc_create_refund function in includes/wc-order-functions.php to get an idea of what the function does.
Hello Gerhard,
Thanks for your reply.
Hm, that’s weird. Apperently the link went wrong. Here it is:https://gist.github.com/YourMark/cc5c02aa624090c453adbdf05aa7e6c5
As you can see there, the tax is in the line items array. Yet it’s not refunded. I know I can debug the entire function step by step. But I was hoping to find an answer here.
I might be doing something wrong after all, or maybe some one encountered the problem before.
-
This reply was modified 7 years, 4 months ago by
Mark Jansen.
I have been going through it. Shipping works now, but the taxes per line still don’t.
I really can’t wrap my head around why not. The data is passed through in all the variables through the entire process. But when the actual refund is created, it doesn’t show up.
When I hook into wc_refund_created (which runs at the end of wc_create_refund()) and I check the $args, I get this:
array(7) {
["amount"]=>
float(52.5)
["reason"]=>
string(14) "VAT correction"
["order_id"]=>
string(5) "41214"
["refund_id"]=>
int(0)
["line_items"]=>
array(2) {
[43380]=>
array(3) {
["qty"]=>
int(1)
["refund_total"]=>
string(9) "42.216667"
["refund_tax"]=>
string(8) "8.443333"
}
[43381]=>
array(3) {
["qty"]=>
int(1)
["refund_total"]=>
string(9) "10.283333"
["refund_tax"]=>
string(8) "2.056667"
}
}
["refund_payment"]=>
bool(false)
["restock_items"]=>
bool(false)
}
The tax is right there, but it doesn’t come up in the refund. This looks like a bug in WC to me.
Unfortunately this still isn’t working. Does anyone have an idea? I have filed a bug report in the GIT Repository.
I’m kind of out of ideas.
@mark-jansen It appears that you found the issue and closed your GitHub report. I will set this thread to resolved, as well.
https://github.com/woocommerce/woocommerce/issues/22157
Hello Jesse,
yes, that is indeed the case. I’m sorry, I forgot all about this topic. Thank you. It is indeed solved.