Modified Shop - Aktionspreise
Verfasst: Di 29. Okt 2013, 13:56
Hallo,
Werden eigentlich die Aktionspreise mit in den Shop übertragen?
Werden eigentlich die Aktionspreise mit in den Shop übertragen?
Code: Alles auswählen
function ProductsSpecialPriceUpdate ()
{
global $_POST;
$ProdID = xtc_db_prepare_input($_POST['pID']);
$Price = xtc_db_prepare_input($_POST['products_ac_price']);
$Status = xtc_db_prepare_input($_POST['status']);
$Expire = xtc_db_prepare_input($_POST['products_ac_date_to']);
if (isset($ProdID))
{
/*
1. Ermitteln ob Produkt bereits einen Spezialpreis hat
2. wenn JA -> Update / NEIN -> INSERT
*/
$sp_sql = "select specials_id from " . TABLE_SPECIALS . " " .
"where products_id='" . (int)$ProdID . "'";
$sp_query = xtc_db_query($sql);
if ($sp = xtc_db_fetch_array($sp_query))
{
// es existiert bereits ein Datensatz -> Update
$SpecialID = $sp['specials_id'];
xtc_db_query(
"update " . TABLE_SPECIALS .
" set specials_new_products_price = '" . $Price . "'," .
" specials_last_modified = now()," .
" expires_date = '" . $Expire .
"' where specials_id = '" . (int)$SpecialID. "'");
print_xml_status (0, $_POST['action'], 'OK', 'UPDATE', '', '');
}
else
{
// Neuanlage
xtc_db_query(
"insert into " . TABLE_SPECIALS .
" (products_id, specials_new_products_price, specials_date_added, expires_date, status) " .
" values ('" . (int)$ProdID . "', '" . $Price . "', now(), '" . $Expire . "', '1')");
print_xml_status (0, $_POST['action'], 'OK', 'APPEND', '', '');
}
}
else
{
print_xml_status (99, $_POST['action'], 'PARAMETER ERROR', '', '', '');
}
}
Code: Alles auswählen
function ProductsSpecialPriceErase ()
{
global $_POST;
$ProdID = xtc_db_prepare_input($_POST['prodid']);
if (isset($ProdID))
{
xtc_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$ProdID . "'");
print_xml_status (0, $_POST['action'], 'OK', '', '', '');
}
else
{
print_xml_status (99, $_POST['action'], 'PARAMETER ERROR', '', '', '');
}
}
Code: Alles auswählen
function ProductsSpecialPriceUpdate ($ProdID)
//BURN alles irgendwie verändert
{
global $_POST;
$Price = xtc_db_prepare_input($_POST['products_ac_price']);
$Expire = xtc_db_prepare_input($_POST['products_ac_date_to']);
if ($Expire > 0) {
$Expire_dd = substr($Expire,0,2);
$Expire_mm = substr($Expire,3,2);
$Expire_yyyy = substr($Expire,6,4);
$Expire = mktime(0,0,0,$Expire_mm,$Expire_dd,$Expire_yyyy);
$Expire = $Expire + 86400;
if ($Expire > time()) {
$Expire = date('Y-m-d', $Expire);
if (isset($ProdID))
{
/*
1. Ermitteln ob Produkt bereits einen Spezialpreis hat
2. wenn JA -> Update / NEIN -> INSERT
*/
$sp_sql = "select specials_id from " . TABLE_SPECIALS . " " .
"where products_id='" . (int)$ProdID . "'";
$sp_query = xtc_db_query($sp_sql);
if ($sp = xtc_db_fetch_array($sp_query)) {
// es existiert bereits ein Datensatz -> Update
$SpecialID = $sp['specials_id'];
xtc_db_query(
"update " . TABLE_SPECIALS .
" set specials_new_products_price = '" . $Price . "'," .
" specials_last_modified = now()," .
" status = 1," .
" expires_date = '" . $Expire .
"' where specials_id = '" . (int)$SpecialID. "'");
//print_xml_status (0, $_POST['action'], 'OK', 'UPDATE', '', '');
} else {
// Neuanlage
xtc_db_query(
"insert into " . TABLE_SPECIALS .
" (products_id, specials_new_products_price, specials_date_added, expires_date, status) " .
" values ('" . (int)$ProdID . "', '" . $Price . "', now(), '" . $Expire . "', '1')");
//print_xml_status (0, $_POST['action'], 'OK', 'APPEND', '', '');
}
} else {
// print_xml_status (99, $_POST['action'], 'PARAMETER ERROR', '', '', '');
}
} else {
xtc_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$ProdID . "'");
}
} else {
xtc_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$ProdID . "'");
}
}
Code: Alles auswählen
ProductsSpecialPriceUpdate($products_id);
Code: Alles auswählen
if (file_exists('cao_produpd_2.php')) { include('cao_produpd_2.php'); }