Seite 1 von 1

Modified Shop - Aktionspreise

Verfasst: Di 29. Okt 2013, 13:56
von AkustikProjekt
Hallo,

Werden eigentlich die Aktionspreise mit in den Shop übertragen?

Re: Modified Shop - Aktionspreise

Verfasst: Di 29. Okt 2013, 21:33
von thomas

Re: Modified Shop - Aktionspreise

Verfasst: Di 29. Okt 2013, 21:52
von AkustikProjekt
Danke Thomas,

Werd mal schauen, ob ich das hin bekomme.

Re: Modified Shop - Aktionspreise

Verfasst: Mi 30. Okt 2013, 11:39
von AkustikProjekt
Hallo,

Habs jetzt probiert in der Schnittstelle zu ändern. Dort gibt es eine Funktion "ProductsSpecialPriceUpdate" und "ProductsSpecialPriceErase".
Ich habe die Tags dort jetzt geändert, allerdings ohne Erfolg. Werden diese Funktionen von CAO verwendet?
Nachfolgend der Code der beiden Funktionen.

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', '', '', '');
  }
}
Danke schon im vorhinein

Re: Modified Shop - Aktionspreise

Verfasst: Mi 30. Okt 2013, 15:54
von Benjamin.Fischer
Hi,

ich habe damals die Funktion angepasst um die Sonderpreis Felder aus CAO zu nutzen.

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 . "'");
	}
}
so sollte es klappen ;)
Die Um im Adminbereich vom Shop nicht irgendwann 1000 abgelaufene Sonderangebote zu haben wird bei jedem Update die Gültigkeit geprüft. Falls abgelaufen wird das Angebot gelöscht.

Re: Modified Shop - Aktionspreise

Verfasst: Mi 30. Okt 2013, 20:42
von AkustikProjekt
Hallo Benjamin,

Danke für Deine Hilfe, aber damit werden die Aktionspreise auch nicht mit übertragen. Muss ich vielleicht noch irgendwelche anderen Einstellungen, zB. in CAO, vornehmen? Ich hab jetzt probiert deine Funktion in die Funktion "ProductsUpdate" einzubauen, da funktionierts.

Re: Modified Shop - Aktionspreise

Verfasst: Mi 30. Okt 2013, 23:34
von Benjamin.Fischer
Hi,

hab da etwas vergessen. die Funktion von oben muss mit

Code: Alles auswählen

ProductsSpecialPriceUpdate($products_id);
noch aufgerufen werden.

Einfach die eine Zeile am Ende von "function ProductsUpdate ()" vor

Code: Alles auswählen

if (file_exists('cao_produpd_2.php')) { include('cao_produpd_2.php'); }
einfügen.

Gruß