Ich bin mal wieder etwas am basteln - sprich ich habe folgendes Modul (http://www.xtc-load.de/2009/06/restpost ... tcommerce/) entdeckt, welches mich interessieren würde. Es werden dabei zwar einige Core Dateien geändert, doch da ich die veränderten Dateien gut dokumentiere ist das halb so schlimm. Das Modul ist eigentlich für die xtc 2.1 Version gedacht. Da jedoch sämtliche Dateien mit den Änderungen übereinstimmen, sollte es eigentlich funktionieren. In meinem Testshop ist nun alles eingebaut und ich kann nun im Admin auch die gewünschten Kategorien als Restpostenkategorien markieren. Das Problem ist, dass ein Restpostenartikel im Warenkorb trotzdem nicht überprüft wird. D.h. wenn man mehr als die erfasste Produktemenge bestellt, geht der Einkauf trotzdem durch. Eigentlich sollte ja folgende Fehlermeldung erscheinen:
Der Wurm dürfte mit aller wahrscheinlichkeit in der Datei cart_action.php stecken
Code: Alles auswählen
<?php
/** ----------------------------------------------------------------------------
**
*F cart_actions.php
**
** WEB-Shop Software http://www.webs.de
**
** Handles the action of the shopping card: add product, delete, ...
**
** ----------------------------------------------------------------------------
** based on:
** (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
** (c) 2002-2003 osCommerce; www.oscommerce.com
** (c) 2003 nextcommerce; www.nextcommerce.org
** (c) 2006 XT-Commerce
**
** Third Party contributions:
** Add A Quickie v1.0 Autor Harald Ponce de Leon
** Credit Class/Gift Vouchers/Discount Coupons (Version 5.10)
** http://www.oscommerce.com/community/contributions,282
** Copyright (c) Strider | Strider@oscworks.com
** Copyright (c Nick Stanko of UkiDev.com, nick@ukidev.com
** Copyright (c) Andre ambidex@gmx.net
** Copyright (c) 2001,2002 Ian C Wilson http://www.phesis.org
**
** Released under the GNU General Public License
**
** @version $Id: cart_actions.php 1772 2010-12-30 13:29:50Z joerg $
** @copyright 2010 WEB-Shop Software http://www.webs.de/
** Autor: Patrik | Restpostenmodul Zeilen: 74-88, 102-115, 211-223, 266-278 am 24.03.2013
** ------------------------------------------------------------------------- */
// Shopping cart actions
if ( isset ($_GET['action']) ) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
if ( !$session_started ) {
xtc_redirect(xtc_href_link(FILENAME_COOKIE_USAGE));
}
if ( DISPLAY_CART == 'true' ) {
$goto = FILENAME_SHOPPING_CART;
$parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
$goto = basename($PHP_SELF);
if ( $_GET['action'] == 'buy_now' ) {
$parameters = array('action', 'pid', 'products_id', 'BUYproducts_id');
} else {
$parameters = array('action', 'pid', 'BUYproducts_id', 'info');
}
}
switch ( $_GET['action'] ) {
// remove product from cart
case 'remove_product':
$prd_id = preg_replace('/[^0-9\{\}]/', '', $_GET['products_id']);
$_SESSION['cart'] -> remove($prd_id);
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
break;
// customer wants to update the product quantity in their shopping cart
case 'update_product':
$cart_delete = is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array();
for ( $i = 0, $n = sizeof($_POST['products_id']); $i < $n; $i ++ ) {
// whish-list
if ( $_POST['submit_target'] == 'wishlist' ) {
if ( in_array($_POST['products_id'][$i], $cart_delete) ) {
$_SESSION['wishList'] -> remove($_POST['products_id'][$i]);
} else {
if ( $_POST['cart_quantity'][$i] > MAX_PRODUCTS_QTY) {
$_POST['cart_quantity'][$i] = MAX_PRODUCTS_QTY;
// Restpostenmodul
$max_qty_query = xtc_db_query('SELECT * FROM '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_TO_CATEGORIES.' pc,
'.TABLE_CATEGORIES.' c
WHERE p.products_id = "'.$_POST['products_id'][$i].'"
AND p.products_id = pc.products_id
AND pc.categories_id = c.categories_id
AND c.restposten_status = 1');
$max_qty = xtc_db_fetch_array($max_qty_query);
if($max_qty['products_quantity'] != 0){
if($cart_quantity > $max_qty['products_quantity']) {
$cart_quantity = $max_qty['products_quantity'];
// $_GET['info_message'] = 'Das Produkt ist nicht mehr ausreichend auf Lager.';
}
}
// Restpostenmodul
}
$attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
$_SESSION['wishList'] -> add_cart($_POST['products_id'][$i],
xtc_remove_non_numeric($_POST['cart_quantity'][$i]),
$attributes, false);
}
$goto = FILENAME_WISH_LIST;
} else { // cart
if ( in_array($_POST['products_id'][$i], $cart_delete) ) {
$_SESSION['cart'] -> remove($_POST['products_id'][$i]);
} else {
if ( $_POST['cart_quantity'][$i] > MAX_PRODUCTS_QTY ) {
$_POST['cart_quantity'][$i] = MAX_PRODUCTS_QTY;
// Restpostenmodul
$max_qty_query = xtc_db_query('SELECT * FROM '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_TO_CATEGORIES.' pc,
'.TABLE_CATEGORIES.' c
WHERE p.products_id = "'.$_POST['products_id'].'"
AND p.products_id = pc.products_id
AND pc.categories_id = c.categories_id
AND c.restposten_status = 1');
$max_qty = xtc_db_fetch_array($max_qty_query);
if($max_qty['products_quantity'] != 0){
if($cart_quantity > $max_qty['products_quantity'])
$cart_quantity = $max_qty['products_quantity'];
$_GET['info_message'] = 'Das Produkt ist nicht mehr ausreichend auf Lager. Bitte den Aktualisieren-Button betätigen um die Menge anzupassen';
}
// Restpostenmodul
}
$attributes = $_POST['id'][$_POST['products_id'][$i]] ? $_POST['id'][$_POST['products_id'][$i]] : '';
$_SESSION['cart'] -> add_cart($_POST['products_id'][$i],
xtc_remove_non_numeric($_POST['cart_quantity'][$i]),
$attributes, false);
}
// END wishlist/cart
}
}
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
break;
// customer adds a product from the products page
case 'add_product':
if ( isset ($_POST['products_id']) && is_numeric($_POST['products_id']) ) {
if ( !is_numeric($_POST['products_qty']) ) {
$_POST['products_qty'] = 1;
}
if ( $_POST['products_qty'] > MAX_PRODUCTS_QTY ) {
$_POST['products_qty'] = MAX_PRODUCTS_QTY;
}
if ( $_POST['submit_target'] == 'wishlist' ) {
$qty = $_SESSION['wishList'] -> get_quantity(xtc_get_uprid($_POST['products_id'], $_POST['id']));
$qty += $_POST['products_qty'];
// make shure that through this action the customer cannot
// extend the MAX_PRODUCTS_QTY
if ( $qty > MAX_PRODUCTS_QTY ) {
$qty = MAX_PRODUCTS_QTY;
}
$_SESSION['wishList'] -> add_cart($_POST['products_id'], $qty, $_POST['id']);
$goto = FILENAME_WISH_LIST;
} else {
$qty = $_SESSION['cart'] -> get_quantity(xtc_get_uprid($_POST['products_id'], $_POST['id']));
$qty += $_POST['products_qty'];
// make shure that through this action the customer cannot
// extend the MAX_PRODUCTS_QTY
if ( $qty > MAX_PRODUCTS_QTY ) {
$qty = MAX_PRODUCTS_QTY;
}
$_SESSION['cart'] -> add_cart($_POST['products_id'], $qty, $_POST['id'], true);
}
}
xtc_redirect(xtc_href_link($goto, 'products_id=' . $_POST['products_id'] . '&'
. xtc_get_all_get_params($parameters)));
break;
case 'check_gift':
require_once (DIR_FS_INC . 'xtc_collect_posts.inc.php');
xtc_collect_posts();
break;
// customer wants to add a quickie to the cart (called from a box)
case 'add_a_quickie':
$quicky = addslashes($_POST['quickie']);
if (GROUP_CHECK == 'true') {
$group_check = "AND group_permission_" . $_SESSION['customers_status']['customers_status_id'] . " = 1 ";
}
$quickie_query = xtc_db_query("SELECT products_fsk18, products_id
FROM " . TABLE_PRODUCTS . "
WHERE products_model = '" . $quicky . "'
AND products_status = '1' " . $group_check);
if ( !xtc_db_num_rows($quickie_query) ) {
if (GROUP_CHECK == 'true') {
$group_check = "AND group_permission_" . $_SESSION['customers_status']['customers_status_id'] . " = 1 ";
}
$quickie_query = xtc_db_query("SELECT products_fsk18, products_id
FROM " . TABLE_PRODUCTS . "
WHERE products_model LIKE '%" . $quicky . "%'
AND products_status = '1' " . $group_check);
}
if ( xtc_db_num_rows($quickie_query) != 1 ) {
xtc_redirect(xtc_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . $quicky, 'NONSSL'));
}
$quickie = xtc_db_fetch_array($quickie_query);
if ( xtc_has_product_attributes($quickie['products_id']) ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
} else {
if ( $quickie['products_fsk18'] == '1' && $_SESSION['customers_status']['customers_fsk18'] == '1' ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
}
if ( $_SESSION['customers_status']['customers_fsk18_display'] == '0' && $quickie['products_fsk18'] == '1' ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $quickie['products_id'], 'NONSSL'));
}
if ($_POST['quickie'] != '') {
$act_qty = $_SESSION['cart'] -> get_quantity(xtc_get_uprid($quickie['products_id'], 1));
if ($act_qty > MAX_PRODUCTS_QTY) {
$act_qty = MAX_PRODUCTS_QTY - 1;
// Restpostenmodul
$qty = 1;
$max_qty_query = xtc_db_query('SELECT * FROM '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_TO_CATEGORIES.' pc,
'.TABLE_CATEGORIES.' c
WHERE p.products_id = "'.$quickie['products_id'].'"
AND p.products_id = pc.products_id
AND pc.categories_id = c.categories_id
AND c.restposten_status = 1');
$max_qty = xtc_db_fetch_array($max_qty_query);
if($max_qty['products_quantity'] != 0){
$qty = $max_qty['products_quantity'];
}
// Restpostenmodul
}
$_SESSION['cart'] -> add_cart($quickie['products_id'], $act_qty +1, 1);
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params(array('action')), 'NONSSL'));
} else {
xtc_redirect(xtc_href_link(FILENAME_ADVANCED_SEARCH_RESULT, 'keywords=' . $quicky, 'NONSSL'));
}
}
break;
// performed by the 'buy now' button in product listings and review page
case 'buy_now':
if ( isset($_GET['BUYproducts_id']) ) {
// check permission to view product
$permission_query = xtc_db_query(sprintf("SELECT group_permission_%u AS customer_group, products_fsk18
FROM %s
WHERE products_id='%u'",
$_SESSION['customers_status']['customers_status_id'],
TABLE_PRODUCTS, $_GET['BUYproducts_id']));
$permission = xtc_db_fetch_array($permission_query);
// check for FSK18
if ( $permission['products_fsk18'] == '1'
&& $_SESSION['customers_status']['customers_fsk18'] == '1' ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id'], 'NONSSL'));
}
if ( $_SESSION['customers_status']['customers_fsk18_display'] == '0'
&& $permission['products_fsk18'] == '1' ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id'], 'NONSSL'));
}
if ( GROUP_CHECK == 'true' ) {
if ( $permission['customer_group'] != '1' ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id']));
}
}
if ( xtc_has_product_attributes($_GET['BUYproducts_id']) ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['BUYproducts_id']));
} else {
if (isset($_SESSION['cart']) ) {
// Restpostenmodul
$qty = 1;
$max_qty_query = xtc_db_query('SELECT * FROM '.TABLE_PRODUCTS.' p, '.TABLE_PRODUCTS_TO_CATEGORIES.' pc,
'.TABLE_CATEGORIES.' c
WHERE p.products_id = "'.(int)$_GET['BUYproducts_id'].'"
AND p.products_id = pc.products_id
AND pc.categories_id = c.categories_id
AND c.restposten_status = 1');
$max_qty = xtc_db_fetch_array($max_qty_query);
if($max_qty['products_quantity'] != 0){
$qty = $max_qty['products_quantity'];
}
// Restpostenmodul
$_SESSION['cart'] -> add_cart($_GET['BUYproducts_id'],
$_SESSION['cart'] -> get_quantity($_GET['BUYproducts_id']) + 1);
} else {
xtc_redirect(xtc_href_link(FILENAME_DEFAULT));
}
}
}
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params(array('action', 'BUYproducts_id'))));
break;
case 'cust_order':
if ( isset($_SESSION['customer_id']) && isset ($_GET['pid']) ) {
if ( xtc_has_product_attributes($_GET['pid']) ) {
xtc_redirect(xtc_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_GET['pid']));
} else {
$_SESSION['cart'] -> add_cart($_GET['pid'], $_SESSION['cart'] -> get_quantity($_GET['pid']) + 1);
}
}
xtc_redirect(xtc_href_link($goto, xtc_get_all_get_params($parameters)));
break;
case 'paypal_express_checkout' :
$o_paypal -> paypal_express_auth_call();
xtc_redirect($o_paypal -> payPalURL);
break;
}
}
?>