Prozent und NEW Flags bei Produkten
Vorwort[Bearbeiten]
Hier eine Möglichkeit wie man bei seinen Produktbilden eine Flag setzen kann, ob der Artikel neu ist oder um wie viel Prozent dieser reduziert wurde.
Änderungswünsche und Anregungen könnt Ihr direkt selber einbauen, über die Diskussion des Beitrages gehen oder an mich richten.
Version[Bearbeiten]
Modul : | Prozent & NEW - Flags |
zur Verfügung gestellt von : | iriedaily |
Installationsanleitung Modified 1.06 : | Ralph_84 |
Wikibeitrag : | Soeldner (Diskussion) 20:10, 1. Mai 2013 (CEST) |
Screenshots[Bearbeiten]
Dateianpassung[Bearbeiten]
BACKUP der Dateien nicht vergessen!
product.php[Bearbeiten]
Datei: /includes/classes/product.php
Suche
//products data array
$productData = array ('PRODUCTS_NAME' => $array['products_name'],
DAVOR einfügen
if ($array['products_date_added'] != '0000-00-00 00:00:00' && MAX_DISPLAY_NEW_PRODUCTS_DAYS != '0') {
$date_new_products = date("Y-m-d", mktime(1, 1, 1, date("m"), date("d") - MAX_DISPLAY_NEW_PRODUCTS_DAYS, date("Y")));
if ($date_new_products." 00:00:00"> $array['products_date_added']) {
$product_isnew = ''; //Produkt ist alt
} else {
$product_isnew = '1'; //Produkt ist neu
}
}
Suche
'PRODUCTS_SHIPPING_IMAGE'=>$shipping_status_image,
DANACH einfügen
'PRODUCTS_OLDNEW'=>$product_isnew,
'PRODUCTS_PRICE_P' => $products_price['percent'],
xtcPrice.php[Bearbeiten]
Datei: /includes/classes/xtcPrice.php
Suche
function xtcFormatSpecial($pID, $sPrice, $pPrice, $format, $vpeStatus = 0) {
if ($format) {
if (!isset($pPrice) || $pPrice == 0)
$discount = 0;
else
$discount = ($pPrice - $sPrice) / $pPrice * 100;
$price = '<span class="productOldPrice"><small>' . INSTEAD . '</small><del>' . $this->xtcFormat($pPrice, $format) . '</del></span><br />' . ONLY . $this->checkAttributes($pID) . $this->xtcFormat($sPrice, $format) . '<br /><small>' . YOU_SAVE . round($discount) . ' % /' . $this->xtcFormat($pPrice - $sPrice, $format) . '</small>';
if ($vpeStatus == 0) {
return $price;
} else {
return array(
'formated' => $price,
'plain' => $sPrice
);
}
} else {
return round($sPrice, $this->currencies[$this->actualCurr]['decimal_places']);
}
}
ERSETZE mit
function xtcFormatSpecial($pID, $sPrice, $pPrice, $format, $vpeStatus = 0) {
if ($format) {
if (!isset($pPrice) || $pPrice == 0)
$discount = 0;
else
$discount = ($pPrice - $sPrice) / $pPrice * 100;
$price = '<span class="productOldPrice"><small>' . INSTEAD . '</small><del>' . $this->xtcFormat($pPrice, $format) . '</del></span><br />' . ONLY . $this->checkAttributes($pID) . $this->xtcFormat($sPrice, $format) . '<br /><small>' . YOU_SAVE . round($discount) . ' % /' . $this->xtcFormat($pPrice - $sPrice, $format) . '</small>';
$price_perc = round($discount);
if ($vpeStatus == 0) {
return $price;
} else {
return array ('formated' => $price, 'plain' => $sPrice, 'percent' => $price_perc);
}
} else {
return round($sPrice, $this->currencies[$this->actualCurr]['decimal_places']);
}
}
verfügbare Variablen[Bearbeiten]
und nun sollte man die neuen Variablen PRODUCTS_OLDNEW & PRODUCTS_PRICE_P in den Templates verwenden können:
[template]/module/product_listing/....html [template]/module/new_products*.html [template]/module/specials.html [template]/module/cross_selling.html
Template anpassen[Bearbeiten]
an gewünschter Stelle im Template folgendes einfügen:
{if $module_data.PRODUCTS_PRICE_P != ''}
<div class="product_special">{$module_data.PRODUCTS_PRICE_P}</div>
{/if}
{if $module_data.PRODUCTS_OLDNEW != '' && $module_data.PRODUCTS_PRICE_P == ''}
<div class="product_isnew"></div>
{/if}
default.php[Bearbeiten]
Datei: /includes/modules/default.php
Suche
$listing_sql = "-- /includes/modules/default.php
SELECT ".$select."
p.products_id,
p.products_ean,
p.products_quantity,
p.products_shippingtime,
p.products_model,
DANACH einfügen
p.products_date_added,
Stylesheet[Bearbeiten]
Zusätzlich müssen noch die entsprechenden CSS-Classes ("product_special", "product_isnew") eingerichtet werden damit ein entsprechendes Bild über das Produktbild gelegt wird.
stylesheet.css[Bearbeiten]
am Ende EINFÜGEN
.product_isnew
{
background: url("img/[NEW_FLAG].png") no-repeat transparent;
height: 80px;
margin-left: 10px;
margin-top: 0px;
position: absolute;
width: 120px;
}
.product_special
{
background: url("img/[SPECIAL_FLAG].png") no-repeat transparent;
color: #FFFFFF;
font-size: 13px;
font-weight: bold;
height: 80px;
line-height: 17px;
margin-left: 10px;
margin-top: 0px;
padding-left: 10px;
padding-top: 0;
position: absolute;
width: 110px;
}
Anmerkungen[Bearbeiten]
Die Einstellungen so in der CSS passen, wenn es ein Original XTC5 Template ist, und die Overlay Bilder eine Größe von 120 x 80 px haben.
Um die Anzeige der Prozente auszublenden, in dem Bereich .product_special die Formatierung des Textes bei:
font-size: 13px;
auf 0px ändern. Somit wird das Prozent nicht mehr angezeigt