Positionen im Warenkorb begrenzen
Aus Wiki | xtcModified eCommerce Shopsoftware
Ich möchte bei jeder Bestellung die folgenden Bedingungen berücksichtigt wissen: Maximale Anzahl der Positionen im Warenkorb (z.B. 5)
Lösung von Franky_n (11.2010), Bezug xtcmodified V1.05 http://www.xtc-modified.org/forum/topic.php?id=9041#post-88772
/includes/classes/shopping_cart.php in Z. 122 nach:
if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { <source lang="php"> if ($this->count_products() < 6) { Dann in Z.138 nach: <source lang="php"> if (isset ($_SESSION['customer_id'])) xtc_db_query("insert into ".TABLE_CUSTOMERS_BASKET_ATTRIBUTES." (customers_id, products_id, products_options_id, products_options_value_id) values ('".$_SESSION['customer_id']."', '".$products_id."', '".$option."', '".$value."')"); } }
das einfügen:
}
Dann vor dem letzten } in der Datei das einfügen:
function count_products() { // get total number of products $total_products = 0; if (is_array($this->contents)) { reset($this->contents); while (list ($products_id,) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; if ($qty >= 1) { $total_products++; } } } return $total_products; }
Das sollte reichen um max 5 Produkte einzufügen unabhängig von der Anzahl. [:)]

