Skip to content
Code-Schnipsel Gruppen Projekte
Commit bc961f4a erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: quiqqer/discount#6

Übergeordneter 7ab9166d
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -7,6 +7,7 @@
namespace QUI\ERP\Discount;
use QUI;
use QUI\ERP\Order\OrderInterface;
use QUI\Users\User;
use QUI\Permissions\Permission;
use QUI\Utils\Security\Orthos;
......@@ -393,10 +394,14 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
}
// category check
if (empty($categories)) {
if (empty($articles) && empty($categories)) {
return true;
}
if (!\is_array($categories)) {
return false;
}
foreach ($categories as $category) {
$productCategories = $Product->getCategories();
......@@ -412,6 +417,40 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc
return false;
}
/**
* @param OrderInterface $Order
* @return bool
*/
public function canUsedInOrder(OrderInterface $Order)
{
if ($this->isActive() === false) {
return false;
}
$Articles = $Order->getArticles();
foreach ($Articles as $Article) {
/* @var $Article QUI\ERP\Accounting\Article */
$id = $Article->getId();
if (!\is_numeric($id)) {
continue;
}
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($id);
if ($this->canUsedWith($Product)) {
return true;
}
} catch (QUI\Exception $Exception) {
continue;
}
}
return false;
}
/**
* Verify the combination between the discounts
*
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren