#1698 closed Bug/Fehler (fixed)
warning beim Kauf aus Kundenkonto, Attribute ohne IDs
| Reported by: | Owned by: | somebody | |
|---|---|---|---|
| Priority: | normal | Milestone: | modified-shop-2.0.5.0 |
| Component: | Shop | Version: | trunk |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: |
Description
Hi,
vielleicht habt ihr schon eine Lösung vorliegen.
Folgendes Szenario:
Ein alter Shop wurde auf 2.0.x aktualisiert.
In der damaligen Shopversion wurden noch keine IDs zu Attributen einer Bestellung gespeichert.
Nutzen Kunden nun die Funktion, Bestellungen aus dem Kundenkonto in den Warenkorb zu legen, gibt es eine PHP-Warnung:
in_array() expects parameter 2 to be array, null given in File [...] includes/classes/shopping_cart.php on Line: 969
Ursache: da die Option-IDs nicht gespeichert wurden, ist diese mit 0 vorbelegt. Ein Attributwert wird nun in einem Array gesucht, dass nicht existiert, weil $option 0 ist
if (!in_array($value,$products_attributes_array[$pID][(int)$option])) {}
Die Bestellung wird dann nicht oder nicht vollständig in den Warenkorb gelegt.
Wie können wir das bestmöglich korrigieren?
Mein Ansatz wäre dieser:
1.) Prüfen, ob es überhaupt ein Array gibt:
includes/classes/shopping_cart.php
function validate_attributes($products_id, $attributes, $flag = '') {
static $products_attributes_array;
if (!is_array($products_attributes_array)) {
$products_attributes_array = array();
}
$check = true;
if (is_array($attributes) && count($attributes)) {
$pID = (int)$products_id;
if (!isset($products_attributes_array[$pID])) {
$products_attributes_array[$pID] = $this->create_products_attributes_array($pID);
}
if(!array_key_exists((int)$option, $products_attributes_array[$pID])) {
return false;
}
foreach($attributes as $option => $value) {
if (!in_array($value,$products_attributes_array[$pID][(int)$option])) {
$check = false;
break;
}
}
}
return $check;
}
2.) Um das Einkaufserlebnis hoch zu halten in der cart_action.php versuchen die Attribut-IDs zu ermitteln, wenn diese noch mit "0" in der Datenbank stehen.
Gibt es Einwände?
Viele Grüße
Andreas
Attachments (0)
Change History (6)
comment:1 by , 6 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:4 by , 6 years ago
| Milestone: | → modified-shop-2.0.5.0 |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
Ich öffne das Ticket nochmal, da der Code nochmal formatiert werden muss gemäß PSR-2.

In 12287: