at the moment I have a function which will refund the invoice on an order. However the shipping is currently also being refunded, which I don’t want.
Is there a way to set the shipping to zero on an invoice refund?
My code is currently this:
private function refundItems($order,$items) {
$refundItems = $items;
$items = [];
foreach ($order->getAllVisibleItems() as $item) {
if (!in_array($item->getId(), $refundItems)) {
continue;
}
// create creditmemo item and add to array
$creditmemoItem = $this->createCreditmemoItem($item);
$items[] = $creditmemoItem;
}
// get the invoice id
$invoiceId = null;
foreach ($order->getInvoiceCollection() as $invoice) {
// this will always point to the latest invoice id
$invoiceId = $invoice->getId();
}
// refund the invoice
$this->refundInvoice->execute(
$invoiceId,
$items,
true, // false = offline / true = online
true // notify customer
);
}
the refundInvoice
uses the MagentoSalesApiRefundInvoiceInterface
class.
So just to re-iterate, the partial refund works fine in the sense that, the individual items chosen are refunded but like I say, the shipping amount is also being refunded, which I don’t want to happen 🙂
Any help would be appreciated.
Cheers