@Bierbaron: Erstmal vielen Dank für den Code...
Nur leider wird die Lagermenge und ob der Kunde einen Checkout machen darf nicht überprüft.
Hier eine angepasste Version.
Es wird überprüft, ob der Checkout erlaubt ist.
- Kunde darf nach checkout_shipping.php
- Wenn Lagerüberwachung aktiv wird überprüft, ob Produkt noch genügend auf Lager ist.
Ausserdem wird ein Produkt aus den Warenkorb gelöscht, bei den der Kunde Menge=0 einträgt.
Fand ich vorher nicht so doll, wenn nur Zahlen über 0 genommen werden. Kann auch ein richtiges Problem werden, wenn der Kunde meint, dass er das Produkt auf 0 gesetzt hat und es nicht gelöscht wird. Vor allen, wenn er im checkout landet.
cart_actions.php (original Version)
suchen...
case 'update_product' :
if (is_object($econda))
$econda->_emptyCart();
for ($i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i++) {
if (in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array ()))) {
$_SESSION['cart']->remove($_POST['products_id'][$i]);
if (is_object($econda))
$econda->_delArticle($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $_POST['old_qty'][$i]);
} else {
if ($_POST['cart_quantity'][$i] > MAX_PRODUCTS_QTY)
$_POST['cart_quantity'][$i] = MAX_PRODUCTS_QTY;
$attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : '';
if (is_object($econda)) {
$old_quantity = $_SESSION['cart']->get_quantity(xtc_get_uprid($_POST['products_id'][$i], $_POST['id'][$i]));
$econda->_updateProduct($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $old_quantity);
}
$_SESSION['cart']->add_cart($_POST['products_id'][$i], xtc_remove_non_numeric($_POST['cart_quantity'][$i]), $attributes, false);
}
}
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
break;
ersetzen mit...
case 'update_product' :
if (is_object($econda))
$econda->_emptyCart();
for ($i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i++) {
if (in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array ()))) {
$_SESSION['cart']->remove($_POST['products_id'][$i]);
if (is_object($econda))
$econda->_delArticle($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $_POST['old_qty'][$i]);
} else {
if ($_POST['cart_quantity'][$i] > MAX_PRODUCTS_QTY)
$_POST['cart_quantity'][$i] = MAX_PRODUCTS_QTY;
$attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : '';
if (is_object($econda)) {
$old_quantity = $_SESSION['cart']->get_quantity(xtc_get_uprid($_POST['products_id'][$i], $_POST['id'][$i]));
$econda->_updateProduct($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $old_quantity);
}
$_SESSION['cart']->add_cart($_POST['products_id'][$i], xtc_remove_non_numeric($_POST['cart_quantity'][$i]), $attributes, false);
if($_POST['cart_quantity'][$i]==0){$_SESSION['cart']->remove($_POST['products_id'][$i]);}
}
}
// xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
// break;
// add by IaN - auto-update cart - 19/Apr/2007
// allow_checkout by MBa
// we have to check click position, cause IE/PC does not send name/value correctly
if (isset($_POST['to_checkout_x'])){
require_once (DIR_FS_INC.'xtc_check_stock.inc.php');
$_SESSION['cart']->calculate();
$_SESSION['any_out_of_stock'] = 0;
$products = $_SESSION['cart']->get_products();
for ($i = 0, $n = sizeof($products); $i < $n; $i ++) {
// Push all attributes information in an array
if (isset ($products[$i]['attributes'])) {
while (list ($option, $value) = each($products[$i]['attributes'])) {
$hidden_options .= xtc_draw_hidden_field('id['.$products[$i]['id'].']['.$option.']', $value);
$attributes = xtc_db_query("select pa.products_attributes_id
from ".TABLE_PRODUCTS_OPTIONS." popt, ".TABLE_PRODUCTS_OPTIONS_VALUES." poval, ".TABLE_PRODUCTS_ATTRIBUTES." pa
where pa.products_id = '".$products[$i]['id']."'
and pa.options_id = '".$option."'
and pa.options_id = popt.products_options_id
and pa.options_values_id = '".$value."'
and pa.options_values_id = poval.products_options_values_id
and popt.language_id = '".(int) $_SESSION['languages_id']."'
and poval.language_id = '".(int) $_SESSION['languages_id']."'");
$attributes_values = xtc_db_fetch_array($attributes);
$products[$i][$option]['products_attributes_id'] = $attributes_values['products_attributes_id'];
}
}
}
$any_out_of_stock = '';
$mark_stock = '';
for ($i = 0, $n = sizeof($products); $i < $n; $i ++) {
if (STOCK_CHECK == 'true') {
$mark_stock = xtc_check_stock($products[$i]['id'], $products[$i]['quantity']);
if ($mark_stock){;
$_SESSION['any_out_of_stock'] = 1;
}
}
$attributes_exist = ((isset ($products[$i]['attributes'])) ? 1 : 0);
if ($attributes_exist == 1) {
reset($products[$i]['attributes']);
while (list ($option, $value) = each($products[$i]['attributes'])) {
if (ATTRIBUTE_STOCK_CHECK == 'true' && STOCK_CHECK == 'true') {
$attribute_stock_check = xtc_check_stock_attributes($products[$i][$option]['products_attributes_id'], $products[$i]['quantity']);
if ($attribute_stock_check){
$_SESSION['any_out_of_stock'] = 1;
}
}
}
}
}
if(!$_SESSION['any_out_of_stock']){
$_SESSION['allow_checkout'] = 'true';
if (STOCK_CHECK == 'true') {
if ($_SESSION['any_out_of_stock'] == 1) {
if (STOCK_ALLOW_CHECKOUT == 'true') {
// write permission in session
$_SESSION['allow_checkout'] = 'true';
} else {
$_SESSION['allow_checkout'] = 'false';
}
} else {
$_SESSION['allow_checkout'] = 'true';
}
}
xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_SHIPPING, xtc_get_all_get_params($parameters), 'SSL'));
break;
}
}
// end add
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
break;
PS: Alles recht unübersichtlich, ich musste doch ne' Menge Code von xtc klauen, aber so geht es.