small refactor on checks if downloadable product

This commit is contained in:
Annika Wolff 2019-12-27 10:03:01 +01:00
parent 35fa80e91f
commit 9fd5ff7f47
2 changed files with 5 additions and 4 deletions

View File

@ -118,15 +118,16 @@ class Cart extends Model implements CartContract
}
/**
* Checks if cart have downloadable items
* Checks if cart has downloadable items
*
* @return boolean
*/
public function haveDownloadableItems()
{
foreach ($this->items as $item) {
if ($item->type == 'downloadable')
if (stristr($item->type,'downloadable') !== false) {
return true;
}
}
return false;

View File

@ -55,7 +55,7 @@ class DownloadableLinkPurchasedRepository extends Repository
*/
public function saveLinks($orderItem)
{
if (! $this->isDownloadableProduct($orderItem)) {
if (! $this->isValidDownloadableProduct($orderItem)) {
return;
}
@ -85,7 +85,7 @@ class DownloadableLinkPurchasedRepository extends Repository
* @param mixed $orderItem Webkul\Sales\Models\OrderItem;
* @return bool
*/
private function isDownloadableProduct($orderItem) : bool {
private function isValidDownloadableProduct($orderItem) : bool {
if (stristr($orderItem->type,'downloadable') !== false && isset($orderItem->additional['links'])) {
return true;
}