From 33b422b29c46c2654aeec1c74e36f84911dfb83a Mon Sep 17 00:00:00 2001 From: Akhtar Khan Date: Tue, 25 Jan 2022 10:47:31 +0530 Subject: [PATCH] resolve issue of downloadable product when it gets cancelled #5663 --- .../src/Repositories/DownloadableLinkPurchasedRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php b/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php index 9036e8758..af88726dd 100644 --- a/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php +++ b/packages/Webkul/Sales/src/Repositories/DownloadableLinkPurchasedRepository.php @@ -106,6 +106,9 @@ class DownloadableLinkPurchasedRepository extends Repository $totalInvoiceQty = $totalInvoiceQty + $invoice_item->qty; } + $orderedQty = $purchasedLink->order_item->qty_ordered; + $totalInvoiceQty = $totalInvoiceQty * ($purchasedLink->download_bought / $orderedQty); + $this->update([ 'status' => $purchasedLink->download_used == $totalInvoiceQty ? $status : $purchasedLink->status, 'download_canceled' => $purchasedLink->download_bought - $totalInvoiceQty,