Warenkorb: nicht-numerische Mengen brechen die Gewichtsberechnung nicht mehr
Yard::weight() multiplizierte Gewicht und Menge ohne Cast. Beide Werte stammen aus Session- bzw. Request-Daten; ein fuehrend-numerischer String wie "2,5" loeste unter PHP 8 die ErrorException "A non-numeric value encountered" aus. Danach war die Position dauerhaft defekt, da reCalculateShippingPrice() bei jedem Aufruf erneut fehlschlug. Cart::update() setzt die Menge ohne Validierung (anders als setQuantity()). Eintrittspunkte waren das quantity-Feld im Shop-POST sowie das Textfeld fuer die Menge im Backoffice-Warenkorb. - Yard: neue cartItemWeight() mit explizitem int-Cast fuer Gewicht und Menge - CardController: nicht-numerische Mengen werden uebersprungen, Schutz gegen ein quantity-Feld, das kein Array ist - OrderController: nutzt das bereits vorhandene $qty (int) statt $data['qty'] roh Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
68d230d4e5
commit
75c2790bd2
4 changed files with 82 additions and 5 deletions
|
|
@ -127,7 +127,14 @@ class CardController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
if (isset($data['quantity'])) {
|
||||
if (! is_array($data['quantity'])) {
|
||||
return back();
|
||||
}
|
||||
foreach ($data['quantity'] as $rowId => $qty) {
|
||||
if (! is_numeric($qty)) {
|
||||
continue;
|
||||
}
|
||||
$qty = (int) $qty;
|
||||
$cartItem = Yard::instance($this->instance)->get($rowId);
|
||||
if ($cartItem) {
|
||||
$product = Product::find($cartItem->id);
|
||||
|
|
@ -135,7 +142,7 @@ class CardController extends Controller
|
|||
$qty = 1;
|
||||
}
|
||||
if ($product) {
|
||||
$additionalWeight = (int) $product->weight * ((int) $qty - (int) $cartItem->qty);
|
||||
$additionalWeight = (int) $product->weight * ($qty - (int) $cartItem->qty);
|
||||
if ($additionalWeight > 0 && Yard::instance($this->instance)->exceedsMaxWeight($additionalWeight)) {
|
||||
\Session::flash('alert-error', __('msg.cart_max_weight_reached'));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue