Here's the exact thing I'm trying to do.
For every orders placed on my WC website, I'm programmatically calculating and adding a fee with a specific name ('RCP'), depending on product attributes.
Let's say that Product A adds 5€, Product B adds 7€,then I'm getting a taxable fee of 12€ (+20% VAT = 14.4€).
But of course when I refund product A, creating a partial refund, it doesn't refund the 5€ on the fee. For orders with large amount of products, it's obviously too complicated for my employee to calculate him/herself how much of the fee is refunded everytime + the new VAT.
I added a hook at 'woocommerce_create_refund' to insert a new $item to my $refund object and then save it. For some reason, it's not working. I based myself on this "https://www.ibenic.com/how-to-create-woocommerce-refunds-programmatically/".
I tried creating an order fee object, but then it's not refunding my original fee item ('RCP').
What am I doing wrong ? Is it possible to refund my specific fee item partially, programmatically ?
Thank you so much in advance for your help.