ich hab es jetzt geschafft, dass mir der Produktkatalog angezeigt wird - dank eurer Hilfe. Wenn man aber einen Artikel in den Warenkorb hinzufügen möchte, passiert nüscht. Der Warenkorb bleibt leer.
BagHira hatte etwas von einem Session-Problem erzählt und da wollte ich fragen ob das hier auch der Fall sein könnte?
Hoffe Ihr habt eine Idee

Viele Grüße
Matt.loker
Modul SC-Product
Code: Alles auswählen
<?php
#Includes
cInclude('classes', 'SC.functions.php');
#Definitions
$shoppingCardID = 39; //ID des ShoppingCardartikels
$curreny = mi18n("€");
if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
$pid=$_REQUEST['productid'];
addtocart($pid,1);
header("location:front_content.php?idcat=$shoppingCardID"); //ID des Shopping-Card Artikels eintragen
exit();
}
?>
<script language="javascript">
function addtocart(pid){
document.buyerform.productid.value=pid;
document.buyerform.command.value='add';
document.buyerform.submit();
}
</script>
<?php
//check if there is a template instance
if (!is_object($tpl)) {
$tpl = new Template;
}
// reset template object
$tpl->reset();
// build Product Card
$sql = "SELECT * FROM sc_products";
$db->query($sql);
while ($db->next_record()) {
$tpl->set('d', 'IMG', $db->f('picture'));
$tpl->set('d', 'NAME', $db->f('name'));
$tpl->set('d', 'DESCRIPTION', $db->f('description'));
$tpl->set('d', 'PRICE', mi18n("Preis"));
$tpl->set('d', 'CURRENCY', $curreny);
$tpl->set('d', 'PRICE-DEC', $db->f('price'));
$tpl->set('d', 'SERIAL', $db->f('serial'));
$tpl->next();
}
$sItems = $tpl->generate('templates/SC-Products_items.html', true, false);
$tpl->set('s', 'items', $sItems);
$tpl->generate('templates/SC-Products_container.html');
?>
Code: Alles auswählen
<?php
#Includes
cInclude('classes', 'SC.functions.php');
#Definitions
$productsID = 3; //ID des Produktübersichtsartikels
$billingID = 40; //ID des Bestellformularartikels
$curreny = mi18n("€");
if($_REQUEST['command']=='delete' && $_REQUEST['pid']>0){
remove_product($_REQUEST['pid']);
}
else if($_REQUEST['command']=='clear'){
unset($SCsession['cart']);
}
else if($_REQUEST['command']=='update'){
$max=count($SCsession['cart']);
for($i=0;$i<$max;$i++){
$pid=$SCsession['cart'][$i]['productid'];
$q=intval($_REQUEST['product'.$pid]);
if($q>0 && $q<=999){
$SCsession['cart'][$i]['qty'] = $q;
}
else{
$msg='Einige Produkte wurden nicht aktualisiert!, Stückzahl muss zwischen 1 und 999 liegen';
}
}
}
?>
<script language="javascript">
function del(pid){
if(confirm('Möchten Sie den Artikel entfernen?')){
document.buyerform;.pid.value=pid;
document.buyerform;.command.value='delete';
document.buyerform;.submit();
}
}
function clear_cart(){
if(confirm('Sie sind dabei Ihren Warenkorb zu leeren, fortsetzen?')){
document.buyerform;.command.value='clear';
document.buyerform;.submit();
}
}
function update_cart(){
document.buyerform;.command.value='update';
document.buyerform;.submit();
}
</script>
<?php
//check if there is a template instance
if (!is_object($tpl)) {
$tpl = new Template;
}
// reset template object
$tpl->reset();
// build shopping card
if(is_array($SCsession['cart'])){
echo '<tr bgcolor="#FFFFFF" style="font-weight:bold"><td>'.mi18n("POS").'</td><td>'.mi18n("Name").'</td><td>'.mi18n("Einzelpreis").'</td><td>'.mi18n("Stückzahl").'</td><td>'.mi18n("Preis").'</td><td>'.mi18n("Optionen").'</td></tr>';
for($i=0;$i<$max;$i++){
if($q==0) continue;
$tpl->set('d', 'PRODUCT_ID', $SCsession['cart'][$i]['productid']);
$tpl->set('d', 'PNAME', get_product_name($pid));
$tpl->set('d', 'QUANTITY', $SCsession['cart'][$i]['qty']);
$tpl->set('d', 'SHOPPING_CARD_POS', $i+1);
$tpl->set('d', 'CURRENCY', $curreny);
$tpl->set('d', 'REMOVE', mi18n("entfernen"));
$tpl->set('d', 'PRICE', get_price($pid));
$tpl->set('d', 'PRICE_ALL', get_price($pid)*$q);
$tpl->next();
}
$message = '<tr><td><b>'.mi18n("Gesamtbestellung").': '.get_order_total().' '.$curreny.'</b></td><td colspan="5" align="right">';
$message .= '<input type="button" value="'.mi18n("Warenkorb löschen").'" onclick="clear_cart()">';
$message .= '<input type="button" value="'.mi18n("Warenkorb aktualisieren").'" onclick="update_cart()">';
$message .= '<input type="button" value="'.mi18n("Bestellung durchführen").'" onclick="window.location="front_content.php?idcat='.$billingID.'">';
$message .= '</td></tr>';
}
else {
$message = '<tr bgColor="#FFFFFF"><td>'.mi18n("Es befinden sich keine Artikel in Ihrem Warenkorb!").'</td>';
}
$tpl->set('s', 'WARENKORBMESSAGE', $message);
$sItems = $tpl->generate('templates/SC-ShoppingCard_items.html', true, false);
$tpl->set('s', 'NACHRICHT', $msg);
$tpl->set('s', 'ITEMS', $sItems);
$tpl->set('s', 'EINKAUF_FORTSETZEN', mi18n("Einkauf fortsetzen"));
$tpl->set('s', 'EINKAUF_FORTSETZEN_URL', 'front_content.php?idcat='.$productsID);
$tpl->generate('templates/SC-ShoppingCard_container.html');
?>
Code: Alles auswählen
<?
function get_product_name($pid){
$result=mysql_query("select name from products where serial=$pid");
$row=mysql_fetch_array($result);
return $row['name'];
}
function get_price($pid){
$result=mysql_query("select price from products where serial=$pid");
$row=mysql_fetch_array($result);
return $row['price'];
}
function remove_product($pid){
$pid=intval($pid);
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
if($pid==$_SESSION['cart'][$i]['productid']){
unset($_SESSION['cart'][$i]);
break;
}
}
$_SESSION['cart']=array_values($_SESSION['cart']);
}
function get_order_total(){
$max=count($_SESSION['cart']);
$sum=0;
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$price=get_price($pid);
$sum+=$price*$q;
}
return $sum;
}
function addtocart($pid,$q){
if($pid<1 or $q<1) return;
if(is_array($_SESSION['cart'])){
if(product_exists($pid)) return;
$max=count($_SESSION['cart']);
$_SESSION['cart'][$max]['productid']=$pid;
$_SESSION['cart'][$max]['qty']=$q;
}
else{
$_SESSION['cart']=array();
$_SESSION['cart'][0]['productid']=$pid;
$_SESSION['cart'][0]['qty']=$q;
}
}
function product_exists($pid){
$pid=intval($pid);
$max=count($_SESSION['cart']);
$flag=0;
for($i=0;$i<$max;$i++){
if($pid==$_SESSION['cart'][$i]['productid']){
$flag=1;
break;
}
}
return $flag;
}
?>