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

feat: #2

Übergeordneter a1760f43
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -114,7 +114,7 @@ define('package/quiqqer/coupons/bin/frontend/controls/CouponCodeInput', [
return;
}
OrderProcess.refreshCurrentStep();
OrderProcess.reload();
});
}
});
......
......@@ -405,7 +405,7 @@ public function isValid()
/**
* Checks if an CouponCode has been redeemed by a user
*
* @param QUI\Users\User $User
* @param QUI\Interfaces\Users\User $User
* @return bool
*/
public function hasUserRedeemed($User)
......@@ -536,6 +536,7 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
}
$priceFactors = [];
$articles = [];
foreach ($coupons as $coupon) {
/* @var $Coupon CouponCode */
......@@ -562,11 +563,65 @@ public function addToOrder(QUI\ERP\Order\OrderInProcess $Order)
);
$priceFactors[] = $PriceFactor;
$articles[] = new QUI\ERP\Accounting\Invoice\Articles\Text([
'id' => '-',
'articleNo' => $Coupon->getCode(),
'title' => $PriceFactor->getTitle(),
'description' => '',
'unitPrice' => 0,
'control' => '',
'quantity' => 1,
'customData' => [
'package' => 'quiqqer/coupon',
'code' => $Coupon->getCode()
]
]);
}
}
if (!empty($priceFactors)) {
$Order->addPriceFactors($priceFactors);
if (empty($priceFactors)) {
return;
}
/**
* @param QUI\ERP\Accounting\Invoice\Articles\Text $Article
* @return boolean
*/
$isInArticles = function ($Article) use ($Order) {
$articles = $Order->getArticles();
$code = $Article->getCustomData()['code'];
foreach ($articles as $Entry) {
if (!method_exists($Entry, 'getCustomData')) {
continue;
}
$customData = $Entry->getCustomData();
if (!$customData || !is_array($customData)) {
continue;
}
if (!isset($customData['package']) || !isset($customData['code'])) {
continue;
}
return $customData['package'] === 'quiqqer/coupon'
&& $customData['code'] === $code;
}
return false;
};
foreach ($articles as $Article) {
/* @var $PriceFactor QUI\ERP\Accounting\Invoice\Articles\Text */
if ($isInArticles($Article) === false) {
$Order->addArticle($Article);
}
}
$Order->update();
$Order->addPriceFactors($priceFactors);
}
}
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren