Hallo zusammen,
ich nutze das V1.1.1 CE Template für einen XT Commerce Shop und bin mehr als zufrieden und konnte fast alles Probleme bislang mit Hilfe des Forums lösen, nun muss ich aber doch eine Frage stellen.
Der Shop ist gekoppelt an eine kostenlose Infoseite die auf Joomla basiert. Nun würde ich gerne auf die Seiten einen Produkt Link hinzufügen. Das klappt auch mittels eines gefundenen Skripts:
//check a refid
$ref = false;
if( isset( $_REQUEST['refid'] ) ){
$ref = true;
$id = $_REQUEST['refid'];
}
//check mwst
$mwst = 0;
if( isset( $_REQUEST['mwst'] ) ){
$mwst = (int)$_REQUEST['mwst'];
}
//config
if( $ref == true ){
$shopdir = "http://www.shopname.de/product_info.php?refID=$id&info=";
}else{
$shopdir = 'http://www.shopname.de.de/product_info.php?info=';
}
$imgdir = 'http://www.shopname.de/images/product_images/thumbnail_images/';
//db connect and select db
$link = mysql_connect( 'localhost', 'user','password') or die("keine Verbindung möglich: " .mysql_error());
mysql_select_db( 'database', $link );
//random product
$sql = "select products_id, products_price, products_image, products_price, products_tax_class_id from products where products_status=1 order by rand() limit 1";
$result = mysql_query( $sql, $link ) or die ("Ungültige Abfrage: " . mysql_error());
if( $product = mysql_fetch_object( $result ) ){
//product options like name, tax
$sql = "select products_name from products_description where products_id=$product->products_id limit 1";
$result = mysql_query( $sql, $link ) or die ("Ungültige Abfrage: " . mysql_error());
$product_data = mysql_fetch_object( $result ) ;
}
mysql_close( $link );
//create html table
$html = '<table border="0" align="center" cellspacing="0" cellpadding="0" width="100%">';
$html .= '<tr>';
$html .= '<td align="left" valign="top"><div class="moduletable" ><h3>';
$html .= substr($product_data->products_name, 0, 20);
$html .= '</h3></div></td>';
$html .= '</tr>';
$html .= '<tr>';
$html .= '<td align="center" valign="top"><p align="center">';
$html .= '<img align="center" src="'. $imgdir . $product->products_image . '">';
$html .= '</p></td>';
$html .= '</tr>';
//check if a mwst is set, if true show price
if( is_int( $mwst ) && $mwst > 0 ){
$price = $product->products_price;
$price += ($product->products_price/100)*$mwst;
$html .= '<tr>';
$html .= '<td align="center" valign="top"><p align="center">';
$html .= '<b>' . number_format($price, 2, ',', ' ') . '</b>';
$html .= '</p></td>';
$html .= '</tr>';
}
$html .= '<tr>';
$html .= '<td align="center" valign="top">';
$pn = sprintf("p%s_%s.html", $product->products_id ,$product_data->products_name);
$pn = str_replace( ' ', '-', $pn );
$html .= '<p align="center"><a href="' . $shopdir . $pn . '">Zum Shop</a></p>';
$html .= '</td>';
$html .= '</tr>';
$html .= '</table>';
echo $html;
Alles anzeigen
Es klappt nun relativ gut, Produkte werden randommäßig geladen aber leider funktioniert der Link "Zum Shop" nicht. Ich denke das hängt mit den benutzerfreundlichen URLs zusammen! Also die $shopdir = "http://www.shopname.de/product_info.php?refID=$id&info="; gibt am Ende eine Seite aus, die nicht auffindbar ist.
Kann mir hier vielleicht jemand helfen??
(PS: noch besser wäre es natürlich wenn man beim Aufruf noch eine ID miteingeben könnte, bin leider in PHP nicht so fit dass ich das machen könnte!)
viele Grüße