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
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
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-Nr. 14603 bestanden
...@@ -78,6 +78,14 @@ public function __construct(bool|int $basketId, QUI\Interfaces\Users\User $User ...@@ -78,6 +78,14 @@ public function __construct(bool|int $basketId, QUI\Interfaces\Users\User $User
$this->List->setUser($User); $this->List->setUser($User);
$this->FrontendMessages = new QUI\ERP\Comments(); $this->FrontendMessages = new QUI\ERP\Comments();
if (is_bool($basketId)) {
try {
$Basket = Handler::getInstance()->getBasketFromUser(QUI::getUserBySession());
$basketId = $Basket->getId();
} catch (QUI\Exception) {
}
}
try { try {
$data = Handler::getInstance()->getBasketData($basketId, $User); $data = Handler::getInstance()->getBasketData($basketId, $User);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
...@@ -220,6 +228,10 @@ public function save(): void ...@@ -220,6 +228,10 @@ public function save(): void
return; return;
} }
if (!$this->User) {
return;
}
// save only product ids with custom fields, we need not more // save only product ids with custom fields, we need not more
$result = []; $result = [];
$products = $this->List->getProducts(); $products = $this->List->getProducts();
......
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