Wer die Ausgabe des Ablaufdatum eines Sonderangebotes quer durch den Shop realisieren möchte, kann sich die Klassen product und xtcPrice wie folgt anpassen.
includes/classes/xtcPrice.phpSuche
// check special
if ($sPrice = $this->xtcCheckSpecial($pID))
return $this->xtcFormatSpecial($pID, $this->xtcAddTax($sPrice, $products_tax), $pPrice, $format, $vpeStatus);
und ersetze es hiermit
// check special
if($special = $this->xtcCheckSpecial($pID))
return $this->xtcFormatSpecial($pID, $this->xtcAddTax($special['price'], $products_tax), $pPrice, $format, $vpeStatus, $special['expires_date']);
Suche
function xtcCheckSpecial($pID) {
$product_query = "select specials_new_products_price
from ".TABLE_SPECIALS."
where products_id = '".$pID."'
and status = '1'";
$product_query = xtDBquery($product_query);
$product = xtc_db_fetch_array($product_query, true);
return $product['specials_new_products_price'];
}
und ersetze es hiermit
function xtcCheckSpecial
($pID) { $product_query = "select specials_new_products_price, expires_date
from ".TABLE_SPECIALS
."
where products_id = '".$pID."'
and status = '1'"; $product_query = xtDBquery
($product_query); $product = xtc_db_fetch_array
($product_query, true); return isset($product['specials_new_products_price']) ?
array('price' => $product['specials_new_products_price'], 'expires_date' => $product['expires_date']) : false;} Suche
function xtcFormatSpecial($pID, $sPrice, $pPrice, $format, $vpeStatus = 0) {
ersetze
function xtcFormatSpecial($pID, $sPrice, $pPrice, $format, $vpeStatus = 0, $expires_date = '') {
und ersetze innerhalb der Funktion
return array ('formated' => $price, 'plain' => $sPrice); mit
return array ('formated' => $price, 'plain' => $sPrice, 'expires_date' => $expires_date); includes/classes/product.phpSuche innerhalb der Funktion buildDataArray()
return array ('COUNT' = > .... und innerhalb des Arrays folgendes hinzufügen
'PRODUCTS_EXPIRES_DATE' => isset($products_price['expires_date']) ?
$this->xtc_date_short($products_price['expires_date']) : '', Ich habe hier mit xtc_date_short() gleich die Formatierung des Datums übernommen. Damit die Funktion in der product Klasse zur Verfügung steht kann man die Funktion in die Klasse aufnehmen
Suchen
class product {
einfügen
// added function xtc_date_short
($raw_date) { if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false; $year = substr($raw_date, 0, 4); $month = (int
)substr($raw_date, 5, 2); $day = (int
)substr($raw_date, 8, 2); $hour = (int
)substr($raw_date, 11, 2); $minute = (int
)substr($raw_date, 14, 2); $second = (int
)substr($raw_date, 17, 2); if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) { return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year)); } else { return preg_replace('/2037' . '$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037))); } } oder man beschäftigt das File System ein wenig und nimmt ein require_once wie von h-h-h vorgeschlagen.
WICHTIG - Die Änderung gilt für alle Seiten für die die Funktion buildDataArray() die Daten bereit stellt, aber es gibt da leider immer noch Ausnahmen wie die product_info.php. Für die product_info.php geht aber folgendes:
includes/modules/product_info.phpSuchen
require_once (DIR_FS_INC.'get_cross_sell_name.inc.php');
darunter hinzufügen
require_once (DIR_FS_INC.'xtc_date_short.inc.php');
Suchen
$info_smarty->assign('PRODUCTS_PRICE', $products_price['formated']);
darunter hinzufügen
$info_smarty->assign('PRODUCTS_EXPIRES_DATE', isset($products_price['expires_date']) ? xtc_date_short
($products_price['expires_date']) : ''); Damit steht dann auch in den Produkt Info Templates {$PRODUCTS_EXPIRES_DATE} zur Verfügung.
Grüße
Sebastian