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

fix(Basket): improve basket id handling and user check in Basket.php

Added a conditional check in src/QUI/ERP/Order/Basket/Basket.php to convert basketId to actual id
from user's session if it is a boolean value. This fixes potential issues that may arise with
non-integer basketIds.

Also, introduced a safeguard check before saving to ensure there is a valid User. If not, the save
function is exited early to prevent potential errors or undesired actions.
Übergeordneter 23af2487
No related branches found
No related tags found
2 Merge Requests!139Update 'next-3.x' with latest changes from 'main',!138fix(Basket): improve basket id handling and user check in Basket.php
Pipeline #14603 bestanden mit Phase
in 2 Minuten und 51 Sekunden
......@@ -78,6 +78,14 @@ public function __construct(bool|int $basketId, QUI\Interfaces\Users\User $User
$this->List->setUser($User);
$this->FrontendMessages = new QUI\ERP\Comments();
if (is_bool($basketId)) {
try {
$Basket = Handler::getInstance()->getBasketFromUser(QUI::getUserBySession());
$basketId = $Basket->getId();
} catch (QUI\Exception) {
}
}
try {
$data = Handler::getInstance()->getBasketData($basketId, $User);
} catch (QUI\Exception $Exception) {
......@@ -220,6 +228,10 @@ public function save(): void
return;
}
if (!$this->User) {
return;
}
// save only product ids with custom fields, we need not more
$result = [];
$products = $this->List->getProducts();
......
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