refactoring part
This commit is contained in:
parent
54c06a94b1
commit
35fa80e91f
|
|
@ -55,8 +55,9 @@ class DownloadableLinkPurchasedRepository extends Repository
|
|||
*/
|
||||
public function saveLinks($orderItem)
|
||||
{
|
||||
if (stristr($orderItem->type,'downloadable') === false || ! isset($orderItem->additional['links']))
|
||||
if (! $this->isDownloadableProduct($orderItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($orderItem->additional['links'] as $linkId) {
|
||||
if (! $productDownloadableLink = $this->productDownloadableLinkRepository->find($linkId))
|
||||
|
|
@ -78,6 +79,19 @@ class DownloadableLinkPurchasedRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true, if ordered item is valid downloadable product with links
|
||||
*
|
||||
* @param mixed $orderItem Webkul\Sales\Models\OrderItem;
|
||||
* @return bool
|
||||
*/
|
||||
private function isDownloadableProduct($orderItem) : bool {
|
||||
if (stristr($orderItem->type,'downloadable') !== false && isset($orderItem->additional['links'])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderItem $orderItem
|
||||
* @param string $status
|
||||
|
|
|
|||
Loading…
Reference in New Issue