Zur Navigation

Preise ändern per PHP [3]

21 Jörg Kruse

In der Funktion kommt die Variable $products_price gar nicht vor - in deinem zweiten Code-Block heißt die Variable $pPrice.

bin mir jetzt allerdings unsicher welche die richtige stelle wäre

Du musst halt wissen, ob die 10 vor oder nach der Steuer addiert werden. Das xtcAddTax() wird dem Namen nach vermutlich die Steuer draufschlagen.

Ich würde das ganze auch gründlich (auf einem Test-System) testen, ob bei deiner Änderung überall plausible Werte herauskommen.

10.01.2014 16:53

22 ShadowLupina

Mache ich^^

Naja ich hab es zum testen nach Show product calculation eingefügt

function xtcGetPrice($pID, $format = true, $qty, $tax_class, $pPrice, $vpeStatus = 0, $cedit_id = 0, $owner = 1, $actual_store = STORE_ID, $PriceAsImage = true)
	{
		$products_tax = '';
		// check if group is allowed to see prices
		if ($this->cStatus['customers_status_show_price'] == '0') return $this->xtcShowNote($vpeStatus, $vpeStatus);
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store && $tax_class != 0) {
				$tax_class = $this->getStoreTax($pID, $actual_store, $tax_class);
			} else {
				$tax_class = $tax_class;
			}
		} else {
			$tax_class = $tax_class;
		}
		// get Tax rate
		if ($cedit_id != 0) {
			$cinfo = hhg_oe_customer_infos($cedit_id);
			$products_tax = hhg_get_tax_rate($tax_class, $cinfo['country_id'], $cinfo['zone_id']);
		} else {
			if (isset($this->TAX[$tax_class])) {
				$products_tax = $this->TAX[$tax_class];
			}
		}
		if ($this->cStatus['customers_status_show_price_tax'] == '0') {
			$products_tax = '';
		}
		// add taxes
		if ($pPrice == 0) {
			$pPrice = $this->getPprice($pID);
		}
		// Normalpreis
			if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$pPrice = $this->getPprice($pID, $owner, $actual_store);
			}
		}
		
		//aufschlag spanische preise
[i]			if ($_SESSION['languages_id'] == 3){
        $pPrice = $pInfo->pPrice + 10;
    }[/i]
		if ($tax_class != 0) {
			$pPrice = $this->xtcAddTax($pPrice, $products_tax);
		}
		
		
		
		//Multiplikatoren
		$calc_sort = split(",", STORE_CALCULATION);
		foreach($calc_sort as $type) {
			if ($type == "manufacturer" || $type == "product_group") {
				$pPrice = $this->addMultiplicator($type, $pID, $pPrice);
			}
		}
		$calc_sql = "SELECT * FROM " . TABLE_PRODUCTS_CALCULATION . " WHERE products_id=" . $pID . " AND store_id=" . $_SESSION['actual_store'];
		$calc_res = hhg_db_query_limit($calc_sql, 1);
		if (is_object($calc_res) && $calc_res->RecordCount() > 0 && $calc_res->fields['multiplier_' . $_SESSION['customers_status']['customers_status_id']] != 0) {
			$pPrice = $pPrice * $calc_res->fields['multiplier_' . $_SESSION['customers_status']['customers_status_id']];
		}
		// Angebot
		if ($sPrice = $this->xtcCheckSpecial($pID, $owner, $actual_store)) {
			if ($products_tax != "") {
				$_tax_price = $this->xtcAddTax($sPrice, $products_tax);
			} else {
				$_tax_price = $sPrice;
			}
			$_price = $this->xtcFormatSpecial($pID, $_tax_price, $pPrice, $format, $vpeStatus, $PriceAsImage);
			if ($_tax_price < $pPrice) {
				return $_price;
			}
		}
		// Gruppenpreis
		$_price = $this->xtcGetGroupPrice($pID, $qty, $owner, $actual_store);
		if (is_numeric($_price)) {
			return $this->xtcFormatSpecialGraduated($pID, $this->xtcAddTax($_price, $products_tax) , $pPrice, $format, $vpeStatus, $pID, $PriceAsImage);
		}
		// Rabatt
		$discount = $this->xtcCheckDiscount($pID, $owner, $actual_store);
		if ($discount) {
			return $this->xtcFormatSpecialDiscount($pID, $discount, $pPrice, $format, $vpeStatus, $PriceAsImage);
		}
		// Normalpreis ausgabes
		if (($PriceAsImage == true) && ($format == true)) {
			return $this->xtcFormatI($pPrice, $format);
		} else {
			return $this->xtcFormat($pPrice, $format, 0, false, $vpeStatus, $pID);
		}
	}

das sorgt allerdings dafür das sich der preis auf 11,90 ändert

das heißt er nimmt ja nur die 10 € + 19 Prozent mehrwertsteuer als preis..also so ganz die richtige stelle kann es nicht sein

oder war der befehl nicht ganz richtig:

if ($_SESSION['languages_id'] == 3){
        $pPrice = $pInfo->pPrice + 10;}


ist mein befehl...sollte ich vlt mit this statt pinfo versuchen

Edit: selbes ergebnis


ach und der preis soll einfach nur um 10 € erhöht werden..also würd ich es jetzt mal nach draufschlagen der steuern versuchen

13.01.2014 12:52 | geändert: 13.01.2014 12:54

23 ShadowLupina

Ok ich hab mir mit echo mal den Wert von pPrice ausgegeben lassen...ist 0...also müsste ich ihn mir wahrscheinlich erst aus der datenbank holen?


ich denke mal das müsste so gehen?

$pPrice = $this->getPprice($pID);

13.01.2014 13:21

24 Jörg Kruse

Woher nimmst du das "$pInfo"?

Addiere einfach die 10 auf die $pPrice

Nach der Steuer:

		if ($tax_class != 0) {
			$pPrice = $this->xtcAddTax($pPrice, $products_tax);
		}
		if ($_SESSION['languages_id'] == 3) {
			$pPrice = $pPrice + 10;
		}

Es geht auch die Kurzschreibweise:

$pPrice += 10;

13.01.2014 13:47

25 ShadowLupina

Das pinfo..war noch aus der anderen funktion hab ich inzwischen durch this ersetzt

Nach der Steuer:

if ($tax_class != 0) {
$pPrice = $this->xtcAddTax($pPrice, $products_tax);
}
if ($_SESSION['languages_id'] == 3) {
$pPrice = $pPrice + 10;
}


Es geht auch die Kurzschreibweise:

$pPrice += 10;

hab ich schon versucht...danach beträgt der preis nur noch 10 €
hab mir mit echo auch pprice ausgegeben lassen und sagt überall null

echo '$_SESSION[\'pPrice\']: ' . (int) $_SESSION['pPrice'];

oder ist der echo aufruf falsch?

13.01.2014 14:03

26 ShadowLupina

ok das session sorgt dafür das immer null angezeigt werden

13.01.2014 15:11

27 ShadowLupina

ah ne

if ($_SESSION['languages_id'] == 3) {
$pPrice = $pPrice + 10;
}

klappt doch^^

13.01.2014 18:31

28 ShadowLupina

Ok ich sehe gerade, dass da doch noch was nicht stimmt....wenn ich das Produkt in den Warenkorb lege...wird der Preis noch mal erhöht

und zwar immer um 11,90 war dem Betrag von 10 € + Mehrwertsteuer beträgt...versteh nur net wieso


mein code noch mal

<?php
/* -----------------------------------------------------------------------------------
$Id: class.xtcprice.php 3368 2010-01-06 14:49:39Z hhgag $

H.H.G. multistore

http://www.hhg-multistore.com/

Copyright (c) 2005-2010 H.H.G. group
--------------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
(c) 2002-2003 osCommerce(currencies.php,v 1.15 2003/03/17); www.oscommerce.com
(c) 2003         nextcommerce (currencies.php,v 1.9 2003/08/17); www.nextcommerce.or
(c) 2003-2005 xt:Commerce (xtcPrice.php); www.xt-commerce.com
--------------------------------------------------------------------------------------
Released under the GNU General Public License
-------------------------------------------------------------------------------------- */
class xtcPrice
{
	var $currencies;
	// class constructor
	function xtcPrice($currency, $cGroup)
	{
		if (($_SESSION['customer_actual_position'] == 'store') || (!$_SESSION['customer_actual_position'] == 'store')) {
			$cstore_id = STORE_ID;
		} elseif ($_SESSION['customer_actual_position'] == 'admin') {
			if ($_SESSION['actual_store'] == 1) {
				$cstore_id = '1';
			} else {
				$cstore_id = $_SESSION['actual_store'];
			}
		}
		$this->currencies = array();
		$this->cStatus = array();
		$this->actualGroup = $cGroup;
		$this->actualCurr = $currency;
		$this->TAX = array();
		$this->SHIPPING = array();
		$this->showFrom_Attributes = true;
		$this->store = $cstore_id;
		// select Currencies
		$currencies_query = "
			SELECT
				*
			FROM
				" . TABLE_CURRENCIES . " AS c,
				" . TABLE_MS_CURRENCIES_TO_STORE . " AS sc
			WHERE
				c.currencies_id = sc.currencies_id
				AND sc.store_" . $cstore_id . " = 1
		";
		$currencies = hhg_db_query($currencies_query, true);
		while (!$currencies->EOF) {
			$this->currencies[$currencies->fields['code']] = array(
				'title' => $currencies->fields['title'],
				'symbol_left' => $currencies->fields['symbol_left'],
				'symbol_right' => $currencies->fields['symbol_right'],
				'decimal_point' => $currencies->fields['decimal_point'],
				'thousands_point' => $currencies->fields['thousands_point'],
				'decimal_places' => $currencies->fields['decimal_places'],
				'value' => $currencies->fields['value']
			);
			$currencies->MoveNext();
		}
		// select Customers Status data
		$customers_status_query = "
			SELECT
				*
			FROM
				" . TABLE_CUSTOMERS_STATUS . "
			WHERE
				customers_status_id = '" . $this->actualGroup . "'
				AND language_id = '" . $_SESSION['languages_id'] . "'
		";
		$customers_status_value = hhg_db_query($customers_status_query, true);
		$this->cStatus = array(
			'customers_status_id' => $this->actualGroup,
			'customers_status_name' => $customers_status_value->fields['customers_status_name'],
			'customers_status_image' => $customers_status_value->fields['customers_status_image'],
			'customers_status_discount' => $customers_status_value->fields['customers_status_discount'],
			'customers_status_ot_discount_flag' => $customers_status_value->fields['customers_status_ot_discount_flag'],
			'customers_status_ot_discount' => $customers_status_value->fields['customers_status_ot_discount'],
			'customers_status_show_price' => $customers_status_value->fields['customers_status_show_price'],
			'customers_status_show_price_tax' => $customers_status_value->fields['customers_status_show_price_tax'],
			'customers_status_add_tax_ot' => $customers_status_value->fields['customers_status_add_tax_ot'],
			'customers_status_payment_unallowed' => $customers_status_value->fields['customers_status_payment_unallowed'],
			'customers_status_shipping_unallowed' => $customers_status_value->fields['customers_status_shipping_unallowed'],
			'customers_status_discount_attributes' => $customers_status_value->fields['customers_status_discount_attributes'],
			'customers_fsk18' => $customers_status_value->fields['customers_fsk18'],
			'customers_fsk18_display' => $customers_status_value->fields['customers_fsk18_display']
		);
		// prefetch tax rates for standard zone
		$zones_data_query = "
			SELECT
				c.tax_class_id AS class
			FROM
				" . TABLE_TAX_CLASS . " AS c
				LEFT JOIN " . TABLE_MS_TAX_CLASS_TO_STORE . " AS c2s
					ON (c.tax_class_id = c2s.tax_class_id)
			WHERE
				c2s.store_" . STORE_ID . " = 1
		";
		$zones_data = hhg_db_query($zones_data_query, true);
		while (!$zones_data->EOF) {
			// calculate tax based on shipping or deliverey country
			if (isset($_SESSION['billto']) && isset($_SESSION['sendto'])) {
				$tax_address_query = "
					SELECT
						ab.entry_country_id,
						ab.entry_zone_id
					FROM
						" . TABLE_ADDRESS_BOOK . " AS ab
						LEFT JOIN " . TABLE_ZONES . " AS z
							ON (ab.entry_zone_id = z.zone_id)
					WHERE
						ab.customers_id = '" . $_SESSION['customer_id'] . "'
						AND ab.address_book_id = '" . ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'
				";
				$tax_address = hhg_db_query($tax_address_query, true);
				$this->TAX[$zones_data->fields['class']] = hhg_get_tax_rate($zones_data->fields['class'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']);
			} else {
				$this->TAX[$zones_data->fields['class']] = hhg_get_tax_rate($zones_data->fields['class']);
			}
			$zones_data->MoveNext();
		}
	}
	// get products Price
	function xtcGetPrice($pID, $format = true, $qty, $tax_class, $pPrice, $vpeStatus = 0, $cedit_id = 0, $owner = 1, $actual_store = STORE_ID, $PriceAsImage = true)
	{
		//echo"Funktionsanfang";
		$products_tax = '';
		// check if group is allowed to see prices
		if ($this->cStatus['customers_status_show_price'] == '0') return $this->xtcShowNote($vpeStatus, $vpeStatus);
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store && $tax_class != 0) {
				$tax_class = $this->getStoreTax($pID, $actual_store, $tax_class);
			} else {
				$tax_class = $tax_class;
			}
		} else {
			$tax_class = $tax_class;
		}
		// get Tax rate
		if ($cedit_id != 0) {
			$cinfo = hhg_oe_customer_infos($cedit_id);
			$products_tax = hhg_get_tax_rate($tax_class, $cinfo['country_id'], $cinfo['zone_id']);
		} else {
			if (isset($this->TAX[$tax_class])) {
				$products_tax = $this->TAX[$tax_class];
			}
		}
		if ($this->cStatus['customers_status_show_price_tax'] == '0') {
			$products_tax = '';
		}
		// add taxes
		if ($pPrice == 0) {
			$pPrice = $this->getPprice($pID);
		}
		// Normalpreis
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$pPrice = $this->getPprice($pID, $owner, $actual_store);
			}
		}
		
		
		
		if ($tax_class != 0) {
			$pPrice = $this->xtcAddTax($pPrice, $products_tax);
		}
		//Multiplikatoren
		$calc_sort = split(",", STORE_CALCULATION);
		foreach($calc_sort as $type) {
			if ($type == "manufacturer" || $type == "product_group") {
				$pPrice = $this->addMultiplicator($type, $pID, $pPrice);
			}
		}
		$calc_sql = "SELECT * FROM " . TABLE_PRODUCTS_CALCULATION . " WHERE products_id=" . $pID . " AND store_id=" . $_SESSION['actual_store'];
		$calc_res = hhg_db_query_limit($calc_sql, 1);
		if (is_object($calc_res) && $calc_res->RecordCount() > 0 && $calc_res->fields['multiplier_' . $_SESSION['customers_status']['customers_status_id']] != 0) {
			$pPrice = $pPrice * $calc_res->fields['multiplier_' . $_SESSION['customers_status']['customers_status_id']];
		}
		// Angebot
		if ($sPrice = $this->xtcCheckSpecial($pID, $owner, $actual_store)) {
			if ($products_tax != "") {
				$_tax_price = $this->xtcAddTax($sPrice, $products_tax);
			} else {
				$_tax_price = $sPrice;
			}
			$_price = $this->xtcFormatSpecial($pID, $_tax_price, $pPrice, $format, $vpeStatus, $PriceAsImage);
			if ($_tax_price < $pPrice) {
				return $_price;
			}
		}
		// Gruppenpreis
		$_price = $this->xtcGetGroupPrice($pID, $qty, $owner, $actual_store);
		if (is_numeric($_price)) {
			return $this->xtcFormatSpecialGraduated($pID, $this->xtcAddTax($_price, $products_tax) , $pPrice, $format, $vpeStatus, $pID, $PriceAsImage);
		}
		// Rabatt
		$discount = $this->xtcCheckDiscount($pID, $owner, $actual_store);
		if ($discount) {
			return $this->xtcFormatSpecialDiscount($pID, $discount, $pPrice, $format, $vpeStatus, $PriceAsImage);
		}
		
		//spanische Preisänderung
	if ($_SESSION['languages_id'] == 3) {
			$pPrice = $pPrice + 10;
		}
		// Normalpreis ausgabes
		if (($PriceAsImage == true) && ($format == true)) {
			// echo "Preis mit Bild!";
			
			
			return $this->xtcFormatI($pPrice, $format);
		} else {
			// echo "Preis ohne Bild!";
			return $this->xtcFormat($pPrice, $format, 0, false, $vpeStatus, $pID);
		}
	}
	function addMultiplicator($type, $pID, $pPrice)
	{
		// Menge eigentlich unötiger Abfragen, jedoch nötig weil Primary ID Namen Total inkonsestent sind!
		if ($type == "manufacturer") {
			$type = $type . "s";
		}
		$sql = "
			SELECT
				" . $type . "_id AS group_id
  			FROM
				" . TABLE_PRODUCTS . "
  			WHERE
				products_id='" . $pID . "'
		";
		$res = hhg_db_query($sql, true);
		if ($res->fields['group_id'] != 0) {
			if ($type == "product_group") {
				$type = "products_groups";
				$type2 = "product_group";
			} else {
				$type2 = $type;
			}
			$sql = "
				SELECT
					multiplier_" . $_SESSION['customers_status']['customers_status_id'] . " AS multipier
	  			FROM
					" . constant("TABLE_" . strtoupper($type) . "_CALCULATION") . "
	  			WHERE
					" . $type2 . "_id='" . $res->fields['group_id'] . "'
					AND store_id='" . $_SESSION['actual_store'] . "'
			";
			$res = hhg_db_query($sql, true);
			if (is_object($res) && $res->RecordCount() > 0 && $res->fields['multipier'] != 0) {
				$pPrice = $pPrice * $res->fields['multipier'];
			}
		}
		return $pPrice;
	}
	function getPprice($pID, $owner = 1, $actual_store = STORE_ID)
	{
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$ppQuery = "
					SELECT
						products_price
					FROM
						" . TABLE_PRODUCTS_PRICE . "
					WHERE
						products_id='" . $pID . "'
						AND store_id = '" . $actual_store . "'
				";
				$ppData = hhg_db_query($ppQuery, true);
				if ($ppData->fields['products_price'] != 0) {
					$pData['products_price'] = $ppData->fields['products_price'];
					return $ppData->fields['products_price'];
				} else {
					$pQuery = "
						SELECT
							products_price
						FROM
							" . TABLE_PRODUCTS . "
						WHERE
							products_id='" . $pID . "'
					";
					$pData = hhg_db_query($pQuery, true);
				}
			} else {
				$pQuery = "
					SELECT
						products_price
					FROM
						" . TABLE_PRODUCTS . "
					WHERE
						products_id='" . $pID . "'
				";
				$pData = hhg_db_query($pQuery, true);
			}
		} else {
			$pQuery = "
				SELECT
					products_price
				FROM
					" . TABLE_PRODUCTS . "
			WHERE
				products_id='" . $pID . "'
			";
			$pData = hhg_db_query($pQuery, true);
		}
		return $pData->fields['products_price'];
	}
	function xtcAddTax($price, $tax)
	{
		$price = $price + ($price / 100 * $tax);
		$price = $this->xtcCalculateCurr($price);
		return $price;
	}
	function xtcCheckDiscount($pID, $owner = 1, $actual_store = STORE_ID)
	{
		// check if group got discount
		if ($this->cStatus['customers_status_discount'] != '0.00') {
			if (SHOW_PRODUCTS_CALCULATION == 'true') {
				if ($owner != $actual_store) {
					$discount_query = "
						SELECT
							products_discount_allowed
						FROM
							" . TABLE_PRODUCTS . " AS p,
							" . TABLE_MS_PRODUCTS_TO_STORE . " AS p2s
							WHERE
							p.products_id = '" . $pID . "'
							AND p.products_id = p2s.products_id
							AND (
									p2s.store_" . $actual_store . " = 1 OR p2s.store_all = 1
								)
					";
				} else {
					$discount_query = "
						SELECT
							products_discount_allowed
						FROM
							" . TABLE_PRODUCTS . "
						WHERE
							products_id = '" . $pID . "'
					";
				}
			} else {
				$discount_query = "
					SELECT
						products_discount_allowed
					FROM
						" . TABLE_PRODUCTS . "
					WHERE
						products_id = '" . $pID . "'
				";
			}
			$dData = hhg_db_query($discount_query, true);
			$discount = $dData->fields['products_discount_allowed'];
			if ($this->cStatus['customers_status_discount'] < $discount) $discount = $this->cStatus['customers_status_discount'];
			if ($discount == '0.00') return false;
			return $discount;
		}
		return false;
	}
	function xtcGetGraduatedPrice($pID, $qty, $owner = 1, $actual_store = STORE_ID)
	{
		if (isset($_SESSION['cart']) && GRADUATED_ASSIGN == 'true') if ($_SESSION['cart']->get_quantity($pID) > $qty) $qty = $_SESSION['cart']->get_quantity($pID);
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$store_query = " AND store_id = '" . $actual_store . "' ";
			} else {
				$store_query = "";
			}
		} else {
			$store_query = '';
		}
		$graduated_price_query = "
			SELECT
				max(quantity) AS qty
			FROM
				" . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "
			WHERE
				products_id='" . $pID . "'
				AND quantity <= '" . $qty . "'
				" . $store_query . "
		";
		$graduated_price_data = hhg_db_query($graduated_price_query, true);
		if ($graduated_price_data->fields['qty']) {
			$graduated_price_query = "
				SELECT
					personal_offer
				FROM
					" . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "
				WHERE
					products_id='" . $pID . "'
					AND quantity='" . $graduated_price_data->fields['qty'] . "'
					" . $store_query . "
			";
			$graduated_price_data = hhg_db_query($graduated_price_query, true);
			$sPrice = $graduated_price_data->fields['personal_offer'];
			if ($sPrice != 0.00) {
				return $sPrice;
			}
		} else {
			return false;
		}
	}
	function xtcGetGroupPrice($pID, $qty, $owner = 1, $actual_store = STORE_ID)
	{
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$store_query = " AND store_id = '" . $actual_store . "' ";
			} else {
				$store_query = "";
			}
		} else {
			$store_query = '';
		}
		$graduated_price_query = "
			SELECT
				max(quantity) AS qty
			FROM
				" . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "
			WHERE
				products_id='" . $pID . "'
				AND quantity<='" . $qty . "'
				" . $store_query . "
		";
		$graduated_price_data = hhg_db_query($graduated_price_query, true);
		if ($graduated_price_data->fields['qty']) {
			$graduated_price_query = "
				SELECT
					personal_offer
				FROM
					" . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "
				WHERE
					products_id='" . $pID . "'
					AND quantity='" . $graduated_price_data->fields['qty'] . "'
					" . $store_query . "
			";
			$graduated_price_data = hhg_db_query($graduated_price_query, true);
			$sPrice = $graduated_price_data->fields['personal_offer'];
			if ($sPrice != 0.00) return $sPrice;
		} else {
			return false;
		}
	}
	function xtcShowNote($vpeStatus, $vpeStatus = 0)
	{
		if ($vpeStatus == 1) return array(
			'formated' => NOT_ALLOWED_TO_SEE_PRICES,
			'plain' => 0
		);
		return NOT_ALLOWED_TO_SEE_PRICES;
	}
	function xtcCheckSpecial($pID, $owner = 1, $actual_store = 1)
	{
		if (SHOW_PRODUCTS_CALCULATION == 'true') {
			if ($owner != $actual_store) {
				$store_query = " and store_id = '" . $actual_store . "' ";
			} else {
				$store_query = "";
			}
		} else {
			$store_query = '';
		}
		$product_query = "
			SELECT
				specials_new_products_price
			FROM
				" . TABLE_SPECIALS . "
			WHERE
				products_id = '" . $pID . "'
				AND status = 1
				" . $store_query . "
		";
		$product = hhg_db_query($product_query, true);
		return $product->fields['specials_new_products_price'];
	}
	function xtcCalculateCurr($price)
	{
		return $this->currencies[$this->actualCurr]['value'] * $price;
	}
	function calcTax($price, $tax)
	{
		return $price * $tax / 100;
	}
	function xtcRemoveCurr($price)
	{
		// check if used Curr != DEFAULT curr
		if (DEFAULT_CURRENCY != $this->actualCurr) {
			return $price * (1 / $this->currencies[$this->actualCurr]['value']);
		} else {
			return $price;
		}
	}
	function xtcRemoveTax($price, $tax)
	{
		$price = ($price / (($tax + 100) / 100));
		return $price;
	}
	function xtcGetTax($price, $tax)
	{
		$tax = $price - $this->xtcRemoveTax($price, $tax);
		return $tax;
	}
	function xtcRemoveDC($price, $dc)
	{
		$price = $price - ($price / 100 * $dc);
		return $price;
	}
	function xtcGetDC($price, $dc)
	{
		$dc = $price / 100 * $dc;
		return $dc;
	}
	function xtcCalculateCurrEx($price, $curr)
	{
		return $price * ($this->currencies[$curr]['value'] / $this->currencies[$this->actualCurr]['value']);
	}
	function getStoreTax($pID, $actual_store, $tax_class)
	{
		$tax_query = "
			SELECT
				products_tax_class_id
			FROM
				" . TABLE_PRODUCTS_PRICE . "
			WHERE
				products_id = '" . $pID . "'
				AND store_id = '" . $actual_store . "'
		";
		$tax = hhg_db_query($tax_query, true);
		if ($tax->RecordCount()) {
			$new_tax_class = $tax->fields['products_tax_class_id'];
		} else {
			$new_tax_class = $tax_class;
		}
		return $new_tax_class;
	}
	function getTaxInfo($products_tax_class_id)
	{
		$tax_info = '';
		if ($_SESSION['customers_status']['customers_status_show_price'] != '0') {
			$tax_rate = $this->TAX[$products_tax_class_id];
			// price incl tax
			if ($tax_rate > 0 && $_SESSION['customers_status']['customers_status_show_price_tax'] != 0) {
				$tax_info = sprintf(TAX_INFO_INCL, $tax_rate . ' %');
			}
			// excl tax + tax at checkout
			if ($tax_rate > 0 && $_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
				$tax_info = sprintf(TAX_INFO_ADD, $tax_rate . ' %');
			}
			// excl tax
			if ($tax_rate > 0 && $_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) {
				$tax_info = sprintf(TAX_INFO_EXCL, $tax_rate . ' %');
			}
		}
		return $tax_info;
	}
	function getProductsOwner($pID)
	{
		$owner_query = "
			SELECT
				products_owner
			FROM
				" . TABLE_PRODUCTS . "
			WHERE
				products_id = '" . $pID . "'
		";
		$owner = hhg_db_query($owner_query, true);
		return $owner->fields['products_owner'];
	}
	function getTaxNotice()
	{
		// no prices
		if ($_SESSION['customers_status']['customers_status_show_price'] == 0) return;
		if ($_SESSION['customers_status']['customers_status_show_price_tax'] != 0) {
			return TAX_INFO_INCL_GLOBAL;
		}
		// excl tax + tax at checkout
		if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
			return TAX_INFO_ADD_GLOBAL;
		}
		// excl tax
		if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) {
			return TAX_INFO_EXCL_GLOBAL;
		}
		return;
	}
	/*
	*
	*    Format Functions
	*
	*
	*
	*/
	function xtcFormat($price, $format = false, $tax_class = 0, $curr = false, $vpeStatus = 0, $pID = 0)
	{
		if ($curr == 'true') $price = $this->xtcCalculateCurr($price);
		if ($tax_class != 0) {
			$products_tax = $this->TAX[$tax_class];
			if ($this->cStatus['customers_status_show_price_tax'] == '0') $products_tax = '';
			$price = $this->xtcAddTax($price, $products_tax);
		}
		if ($format == 'true') {
			$Pprice = number_format($price, $this->currencies[$this->actualCurr]['decimal_places'], $this->currencies[$this->actualCurr]['decimal_point'], $this->currencies[$this->actualCurr]['thousands_point']);
			$Pprice = $this->currencies[$this->actualCurr]['symbol_left'] . ' ' . $Pprice . ' ' . $this->currencies[$this->actualCurr]['symbol_right'];
			if ($vpeStatus == 0) {
				return $Pprice;
			} else {
				return array(
					'formated' => $Pprice,
					'plain' => $price
				);
			}
		} else {
			return $price;
		}
	}
	function xtcFormatSpecialDiscount($pID, $discount, $pPrice, $format = false, $vpeStatus = 0, $priceAsImage)
	{
		$sPrice = $pPrice - ($pPrice / 100) * $discount;
		if ($format == true && ($priceAsImage == false || USE_PRICE_IMAGES == "false")) {
			$price = array();
			$price['instead'] = INSTEAD;
			$price['instead_price'] = $this->xtcFormat($pPrice, $format);
			$price['only'] = ONLY;
			$price['only_price'] = $this->xtcFormat($sPrice, $format);
			$price['discount_text'] = YOU_SAVE;
			$price['discount'] = $discount . '%';
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} elseif ($format == true && $priceAsImage == true && USE_PRICE_IMAGES == "true") {
			$price = array();
			$price['instead'] = INSTEAD;
			$price['instead_price'] = $this->xtcFormatI($pPrice, $format, 0, false, true);
			$price['only'] = ONLY;
			$price['only_price'] = $this->xtcFormatI($sPrice, $format);
			$price['discount_text'] = YOU_SAVE;
			$price['discount'] = $discount . '%';
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} else {
			return $sPrice;
		}
	}
	function xtcFormatSpecial($pID, $sPrice, $pPrice, $format = false, $vpeStatus = 0, $priceAsImage)
	{
		if ($format == true && ($priceAsImage == false || USE_PRICE_IMAGES == "false")) {
			$price = array();
			$price['instead'] = INSTEAD;
			$price['instead_price'] = $this->xtcFormat($pPrice, $format);
			$price['only'] = ONLY;
			$price['only_price'] = $this->xtcFormat($sPrice, $format);
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} else if ($format == true && $priceAsImage == true && USE_PRICE_IMAGES == "true") {
			$price = array();
			$price['instead'] = INSTEAD;
			$price['instead_price'] = $this->xtcFormatI($pPrice, $format, 0, false, true);
			$price['only'] = ONLY;
			$price['only_price'] = $this->xtcFormatI($sPrice, $format);
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} else {
			return $sPrice;
		}
	}
	function xtcFormatSpecialGraduated($pID, $sPrice, $pPrice, $format = false, $vpeStatus = 0, $pID, $priceAsImage)
	{
		if ($pPrice == 0) return $this->xtcFormat($sPrice, $format, 0, false, $vpeStatus);
		if ($discount = $this->xtcCheckDiscount($pID)) $sPrice-= $sPrice / 100 * $discount;
		if ($format == true && ($priceAsImage == false || USE_PRICE_IMAGES == "false")) {
			if ($sPrice != $pPrice) {
				$price = array();
				$price['instead'] = MSRP;
				$price['instead_price'] = $this->xtcFormat($pPrice, $format);
				$price['only'] = YOUR_PRICE;
				$price['only_price'] = $this->xtcFormat($sPrice, $format);
			} else {
				$price = FROM . $this->xtcFormat($sPrice, $format);
			}
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} else if ($format == true && $priceAsImage == true && USE_PRICE_IMAGES == "true") {
			if ($sPrice != $pPrice) {
				$price = array();
				$price['instead'] = MSRP;
				$price['instead_price'] = $this->xtcFormatI($pPrice, $format, 0, false, true);
				$price['only'] = YOUR_PRICE;
				$price['only_price'] = $this->xtcFormatI($sPrice, $format);
			} else {
				$price = FROM . $this->xtcFormatI($sPrice, $format);
			}
			if ($vpeStatus == 0) {
				return $price;
			} else {
				return array(
					'formated' => $price,
					'plain' => $sPrice
				);
			}
		} else {
			return $sPrice;
		}
	}
	function get_decimal_places($code)
	{
		return $this->currencies[$this->actualCurr]['decimal_places'];
	}
	function xtcFormatI($price, $format, $tax_class = 0, $curr = false, $old = false)
	{
		if ($curr == 'true') $price = $this->xtcCalculateCurr($price);
		if ($tax_class != 0) {
			$products_tax = $this->TAX[$tax_class];
			if ($this->cStatus['customers_status_show_price_tax'] == '0') $products_tax = '';
			$price = $this->xtcAddTax($price, $products_tax);
		}
		if ($format == true) {
			$Pprice = number_format($price, $this->currencies[$this->actualCurr]['decimal_places'], $this->currencies[$this->actualCurr]['decimal_point'], $this->currencies[$this->actualCurr]['thousands_point']);
			$Pprice = $this->currencies[$this->actualCurr]['symbol_left'] . ' ' . $Pprice . ' ' . $this->currencies[$this->actualCurr]['symbol_right'];
			if ($this->currencies[$this->actualCurr]['symbol_left'] != "") {
				$curr_code = $this->currencies[$this->actualCurr]['symbol_left'];
			} else {
				$curr_code = $this->currencies[$this->actualCurr]['symbol_right'];
			}
			if (USE_PRICE_IMAGES == 'true') {
				$price = $this->xtcPriceAsImage($Pprice, $curr_code, $old);
			} else {
				$price = $Pprice;
			}
			return $price;
		} else {
			return $price;
		}
	}
	function xtcPriceAsImage($price, $curr_code, $old)
	{
		$imagePath = DIR_WS_THEME_FOLDER . CURRENT_THEME . '/img/digits/';
		if ($old == 'true') {
			$_old = '_old';
		} else {
			$_old = NULL;
		}
		$price = explode(" ", trim((string)$price));
		if ($this->currencies[$this->actualCurr]['symbol_left'] != "") {
			$_curr = trim($price[0]);
			$_price = trim($price[1]);
		} elseif ($this->currencies[$this->actualCurr]['symbol_right'] != "") {
			$_curr = trim($price[1]);
			$_price = trim($price[0]);
		}
		$price = explode($this->currencies[$this->actualCurr]['decimal_point'], trim($_price));
		$suffix = $price[1];
		$prefix = str_replace($this->currencies[$this->actualCurr]['thousands_point'], "", $price[0]);
		$pre = '';
		for ($i = 0; $i < strlen($prefix); $i++) {
			if (file_exists($imagePath . substr($prefix, $i, 1) . $_old . ".png")) {
				$pre.= '<img src="' . DIR_WS_CATALOG . $imagePath . substr($prefix, $i, 1) . $_old . '.png" alt="' . substr($prefix, $i, 1) . $_old . '" />';
			} else {
				$pre.= substr($prefix, $i, 1);
			}
		}
		if (file_exists($imagePath . $this->currencies[$this->actualCurr]['decimal_point'] . $_old . '.png')) {
			$pre.= '<img src="' . DIR_WS_CATALOG . $imagePath . $this->currencies[$this->actualCurr]['decimal_point'] . $_old . '.png" alt="' . $this->currencies[$this->actualCurr]['decimal_point'] . $_old . '" />';
		} else {
			$pre.= $this->currencies[$this->actualCurr]['decimal_point'];
		}
		$su = '';
		if ($suffix[0] == 0 && $suffix[1] == 0) {
			if (file_exists($imagePath . "-" . $_old . ".png")) {
				$su.= '<img src="' . DIR_WS_CATALOG . $imagePath . '-' . $_old . '.png" alt="-' . $_old . '" />';
			} else {
				$su.= "-";
			}
		} else {
			for ($i = 0; $i < strlen($suffix); $i++) {
				if (file_exists($imagePath . substr($suffix, $i, 1) . "small" . $_old . ".png")) {
					$su.= '<img src="' . DIR_WS_CATALOG . $imagePath . substr($suffix, $i, 1) . 'small' . $_old . '.png" alt="' . substr($suffix, $i, 1) . 'small' . $_old . '" />';
				} else {
					$su.= substr($suffix, $i, 1);
				}
			}
		}
		if (file_exists($imagePath . strtolower($curr_code) . $_old . ".png")) {
			$curr = '<img src="' . DIR_WS_CATALOG . $imagePath . strtolower($curr_code) . $_old . '.png" alt="' . strtolower($curr_code) . $_old . '" />';
		} else {
			$curr = $curr_code;
		}
		if ($this->currencies[$this->actualCurr]['symbol_left'] != "") {
			return $curr . $pre . $su;
		} else {
			return $pre . $su . $curr;
		}
	}
}
?>

14.01.2014 12:10 | geändert: 14.01.2014 12:17

29 ShadowLupina

Und wegen dem Betreiber der Shopsoftware, die wollen keine Hilfestellung mehr geben...wenn nicht nen Supportticket gekauft wird

14.01.2014 12:20

30 ShadowLupina

Das ist die Funktion für den Einkaufswagen: class.shopping_cart.php

<?php
/* -----------------------------------------------------------------------------------------
$Id: class.shopping_cart.php 3669 2010-02-02 18:25:19Z hhgag $

H.H.G. multistore

http://www.hhg-multistore.com/

Copyright (c) 2005-2010 H.H.G. group
-----------------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
(c) 2002-2003 osCommerce(shopping_cart.php,v 1.32 2003/02/11); www.oscommerce.com
(c) 2003	 nextcommerce (shopping_cart.php,v 1.21 2003/08/17); www.nextcommerce.org
(c) 2003-2005 xt:commerce (shopping_cart.php 1534 2006-08-20); www.xt-commerce.com

Released under the GNU General Public License
-----------------------------------------------------------------------------------------
Third Party contributions:

Customers Status v3.x  (c) 2002-2003 Copyright Elari elari@free.fr | www.unlockgsm.com/dload-osc/ | CVS : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/elari/?sortby=date#dirlist

Credit Class/Gift Vouchers/Discount Coupons (Version 5.10)
http://www.oscommerce.com/community/contributions,282
Copyright (c) Strider | Strider@oscworks.com
Copyright (c  Nick Stanko of UkiDev.com, nick@ukidev.com
Copyright (c) Andre ambidex@gmx.net
Copyright (c) 2001,2002 Ian C Wilson http://www.phesis.org

Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
// include needed functions
require_once (DIR_FS_CORE_INC . 'inc.hhg_create_random_value.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_get_prid.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_draw_form.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_draw_input_field.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_image_submit.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_get_tax_description.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_get_products_name.php');
require_once (DIR_FS_CORE_INC . 'inc.hhg_get_store_name.php');
class shopping_cart
{
	var $contents, $total, $weight, $cartID, $content_type;
	function __construct()
	{
		$this->cleanup_cart();
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function add_cart($products_id, $qty = 1, $tmp_store_id = STORE_ID, $optionCategs = false)
	{
		global $xtPrice;
		$compare_option = '';
		if (is_array($optionCategs)) {
			foreach($optionCategs as $key => $option_id) {
				foreach($_SESSION['variants_config'][$products_id] as $_key => $options) {
					if (array_key_exists($key, $options)) {
						$_SESSION['variants_config'][$products_id][$_key][$key]['selected'] = $option_id;
					}
				}
				if (is_array($option_id)) {
					foreach($option_id as $__option_id) {
						$compare_option.= $key . ',' . $__option_id . ';';
					}
				} else {
					$compare_option.= $key . ',' . $option_id . ';';
				}
			}
		} // merge options to string
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$basket_table_option = TABLE_MS_CUSTOMERS_BASKET_OPTIONS;
			$insert_sql = "	SELECT customers_basket_id, products_id, products_model, products_options, products_owner, products_price, products_price_ek, products_quantity, products_final_price, products_weight, products_shippingtime
	    						FROM " . $basket_table . "
	    						WHERE 	products_id='" . $products_id . "' and
	    								customers_id = '" . $_SESSION['customer_id'] . "' and
	    								products_options = '" . $compare_option . "' AND
	    								store_id = '" . $tmp_store_id . "'";
			$cart = hhg_db_query($insert_sql);
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$basket_table_option = TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP;
			$sid = session_id();
			$insert_sql = "select customers_basket_id, sid, products_id, products_model, products_options, products_owner, products_price, products_price_ek, products_quantity, products_final_price, products_weight, products_shippingtime
	    					from " . $basket_table . "
	    					where
	    						products_id='" . $products_id . "' and
	    						products_options = '" . $compare_option . "' AND
	    						sid = '" . $sid . "' and
	    						store_id = '" . $tmp_store_id . "'";
			$cart = hhg_db_query($insert_sql);
		}
		if ($cart->RecordCount() == 0) {
			$c_action = 'insert';
			$qty = $qty;
		} else {
			$c_action = 'update';
			$qty = $qty + $cart->fields['products_quantity'];
		}
		$product = hhg_db_query("	SELECT products_id, products_model, products_owner, products_price, products_price_ek, products_tax_class_id, products_weight, products_shippingtime
								FROM " . TABLE_PRODUCTS . "
								WHERE products_id='" . $products_id . "'");
		if ($product->RecordCount() > 0) {
			$price = $xtPrice->xtcGetPrice($products_id, false, $qty, 0, $product->fields['products_price'], 0, 0, $product->fields['products_owner'], $tmp_store_id);
			$final_price = ($price * $qty);
			if (isset($_SESSION['customer_id'])) {
				$sid = $_SESSION['customer_id'];
			} else {
				$sid = $sid;
			}
			$sql_data_array = array(
				'customers_id' => $sid,
				'products_id' => $products_id,
				'products_model' => $product->fields['products_model'],
				'products_options' => $compare_option,
				'products_owner' => $product->fields['products_owner'],
				'products_quantity' => $qty,
				'products_price' => $price,
				'products_price_ek' => $product->fields['products_price_ek'],
				'products_tax_class' => $product->fields['products_tax_class_id'],
				'products_final_price' => $final_price,
				'products_weight' => $product->fields['products_weight'],
				'products_shippingtime' => $product->fields['products_shippingtime'],
				'customers_basket_date_added' => date('Ymd') ,
				'store_id' => $tmp_store_id
			);
			if ($c_action == 'insert') {
				if (!isset($_SESSION['customer_id'])) {
					$sid_array = array(
						'sid' => $sid
					);
					$sql_data_array = array_merge($sql_data_array, $sid_array);
				}
				$basket_id = hhg_db_perform($basket_table, $sql_data_array);
				if (is_array($optionCategs) && $basket_id != false) {
					foreach($optionCategs as $key => $option_id) {
						if (is_array($option_id)) {
							foreach($option_id as $__option_id) {
								$sql_data_options_array = array(
									'customers_basket_id' => $basket_id,
									'products_id' => $products_id,
									'option_categ' => $key,
									'option_id' => $__option_id,
									'store_id' => $tmp_store_id
								);
								hhg_db_perform($basket_table_option, $sql_data_options_array);
							}
						} else {
							$sql_data_options_array = array(
								'customers_basket_id' => $basket_id,
								'products_id' => $products_id,
								'option_categ' => $key,
								'option_id' => $option_id,
								'store_id' => $tmp_store_id
							);
							hhg_db_perform($basket_table_option, $sql_data_options_array);
						}
					}
				}
			} elseif ($c_action == 'update') {
				if (isset($_SESSION['customer_id'])) {
					hhg_db_perform($basket_table, $sql_data_array, 'update', 'products_options="' . $compare_option . '" AND products_id = ' . hhg_db_prepare($products_id) . ' and customers_id = ' . hhg_db_prepare($_SESSION['customer_id']) . ' and store_id = ' . hhg_db_prepare($tmp_store_id) . '');
				} else {
					hhg_db_perform($basket_table, $sql_data_array, 'update', 'products_options="' . $compare_option . '" AND products_id = ' . hhg_db_prepare($products_id) . ' and sid = ' . hhg_db_prepare($sid) . ' and store_id = ' . hhg_db_prepare($tmp_store_id) . '');
				}
			}
		}
		$this->cartID = $this->generate_cart_id();
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function update_product($products_id, $cart_id, $qty = 1, $tmp_store_id = STORE_ID)
	{
		global $xtPrice;
		$store_qry = $this->get_store_filter($tmp_store_id);
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$cart_query = "
				SELECT
					customers_basket_id,
					products_id,
					products_model,
					products_owner,
					products_price,
					products_price_ek,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime
				FROM
					" . $basket_table . "
				WHERE
					products_id = '" . $products_id . "'
					AND customers_id = '" . $_SESSION['customer_id'] . "'
					" . $store_qry . "
			";
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$cart_query = "
				SELECT
					customers_basket_id,
					sid,
					products_id,
					products_model,
					products_owner,
					products_price,
					products_price_ek,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime
				FROM
					" . $basket_table . "
				WHERE
					products_id = '" . $products_id . "'
					AND sid = '" . $sid . "'
					" . $store_qry . "
			";
		}
		$cart = hhg_db_query($cart_query);
		$product_query = "
			SELECT
				products_id,
				products_model,
				products_owner,
				products_price,
				products_price_ek,
				products_tax_class_id,
				products_weight,
				products_shippingtime
			FROM
				" . TABLE_PRODUCTS . "
			WHERE
				products_id='" . $products_id . "'
		";
		$product = hhg_db_query($product_query);
		if ($product->RecordCount()) {
			if ($qty < 0) {
				$qty = 0;
			}
			$base_raw_price = $product->fields['products_price'];
			$price = $xtPrice->xtcGetPrice($products_id, false, $qty, 0, $product->fields['products_price'], '', '', $product->fields['products_owner'], $tmp_store_id, false);
			$final_price = ($price * $qty);
			$sql_data_array = array(
				'products_quantity' => $qty,
				'products_price' => $price,
				'products_price_ek' => $product->fields['products_price_ek']*$qty,
				'products_final_price' => $final_price,
				'customers_basket_date_added' => date('Ymd')
			);
			if (isset($_SESSION['customer_id'])) {
				$customer = "  AND customers_id = " . hhg_db_prepare($_SESSION['customer_id']) . " ";
			} else {
				$customer = "  AND sid = " . hhg_db_prepare($sid) . " ";
			}
			if ($qty == 0) {
				$sql = "
					DELETE
					FROM
						" . $basket_table . "
		    				WHERE
						products_id = " . hhg_db_prepare($products_id) . "
						AND customers_basket_id = " . hhg_db_prepare($cart_id) . "
						" . $customer . "
						" . $store_qry . "
				";
				hhg_db_query($sql);
			} else {
				hhg_db_perform($basket_table, $sql_data_array, 'update', 'products_id = ' . hhg_db_prepare($products_id) . ' AND customers_basket_id = ' . hhg_db_prepare($cart_id) . $customer . $store_qry . '');
			}
		}
		$this->cartID = $this->generate_cart_id();
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function sync_cart($tmp_store_id = STORE_ID, $old_session = "")
	{
		global $xtPrice;
		$store_qry = $this->get_store_filter($tmp_store_id);
		if ($old_session != "") {
			$sid = $old_session;
		} else {
			$sid = session_id();
		}
		$tmp_cart_query = "
			SELECT
				*
			FROM
				" . TABLE_MS_CUSTOMERS_BASKET_TMP . "
								WHERE
				sid = '" . $sid . "'
				" . $store_qry . "
		";
		$tmp_cart = hhg_db_query($tmp_cart_query);
		while (!$tmp_cart->EOF) {
			$check_query = "
				SELECT
					*
				FROM
					" . TABLE_MS_CUSTOMERS_BASKET . "
				WHERE
					products_id='" . $tmp_cart->fields['products_id'] . "'
					AND customers_id = '" . $_SESSION['customer_id'] . "'
					AND products_options = '" . $tmp_cart->fields['products_options'] . "'
					" . $store_qry . "
			";
			$check = hhg_db_query($check_query);
			$this->cartID = $this->generate_cart_id();
			if ($check->RecordCount() >= 1 && $tmp_cart->fields['products_options'] == $check->fields['products_options']) { // product available, just update
				$product = hhg_db_query("select products_id, products_model, products_owner, products_price, products_tax_class_id, products_weight, products_shippingtime from " . TABLE_PRODUCTS . " where products_id='" . $tmp_cart->fields['products_id'] . "'");
				$qty = $tmp_cart->fields['products_quantity'] + $check->fields['products_quantity'];
				$price = $xtPrice->xtcGetPrice($tmp_cart->fields['products_id'], 'false', $qty, '', $product->fields['products_price'], '', '', $product->fields['products_owner'], $tmp_store_id, false);
				$final_price = ($price * $qty);
				$sql_data_array = array(
					'products_model' => $product->fields['products_model'],
					'products_weight' => $product->fields['products_weight'],
					'products_shippingtime' => $product->fields['products_shippingtime'],
					'products_quantity' => $qty,
					'products_price' => $price,
					'products_price_ek' => $product->fields['products_price_ek']*$qty,
					'products_final_price' => $final_price,
					'customers_basket_date_added' => date('Ymd')
				);
				$this->contents[$tmp_cart->fields['products_id']] = array(
					'qty' => $tmp_cart->fields['products_quantity']
				);
				hhg_db_perform(TABLE_MS_CUSTOMERS_BASKET, $sql_data_array, 'update', 'customers_basket_id = ' . hhg_db_prepare($check->fields['customers_basket_id']) . ' and customers_id = ' . hhg_db_prepare($_SESSION['customer_id']) . ' and store_id = ' . hhg_db_prepare($tmp_store_id) . '');
			} else { // new product
				$sql_data_array = array(
					'customers_id' => $_SESSION['customer_id'],
					'products_id' => $tmp_cart->fields['products_id'],
					'products_model' => $tmp_cart->fields['products_model'],
					'products_options' => $tmp_cart->fields['products_options'],
					'products_owner' => $tmp_cart->fields['products_owner'],
					'products_alternate_name' => $tmp_cart->fields['products_alternate_name'],
					'products_alternate_desc' => $tmp_cart->fields['products_alternate_desc'],
					'products_quantity' => $tmp_cart->fields['products_quantity'],
					'products_price' => $tmp_cart->fields['products_price'],
					'products_price_ek' => $tmp_cart->fields['products_price_ek'],
					'products_tax_class' => $tmp_cart->fields['products_tax_class'],
					'products_final_price' => $tmp_cart->fields['products_final_price'],
					'products_weight' => $tmp_cart->fields['products_weight'],
					'products_shippingtime' => $tmp_cart->fields['products_shippingtime'],
					'customers_basket_date_added' => date('Ymd') ,
					'store_id' => $tmp_store_id
				);
				$this->contents[$tmp_cart->fields['products_id']] = array(
					'qty' => $tmp_cart->fields['products_quantity']
				);
				$insert_id = hhg_db_perform(TABLE_MS_CUSTOMERS_BASKET, $sql_data_array);
				if ($tmp_cart->fields['products_options'] != "") {
					$options = hhg_db_query("	select *
	    						from " . TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP . "
	    						where
	    							customers_basket_id='" . $tmp_cart->fields['customers_basket_id'] . "' and
	    							store_id = '" . $_SESSION['actual_store'] . "'");
					while (!$options->EOF) {
						$sql_data_array = array(
							'customers_basket_id' => $insert_id,
							'products_id' => $options->fields['products_id'],
							'option_categ' => $options->fields['option_categ'],
							'option_id' => $options->fields['option_id'],
							'store_id' => $options->fields['store_id'],
						);
						hhg_db_perform(TABLE_MS_CUSTOMERS_BASKET_OPTIONS, $sql_data_array);
						$options->MoveNext();
					}
				}
			}
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET_TMP . " where customers_basket_id = '" . $tmp_cart->fields['customers_basket_id'] . "'");
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP . " where customers_basket_id = '" . $tmp_cart->fields['customers_basket_id'] . "' and store_id=" . $_SESSION['actual_store']);
			$tmp_cart->MoveNext();
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function del_cart($customers_basket_id)
	{
		if (!isset($_SESSION['customer_id'])) {
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET_TMP . " where customers_basket_id = '" . $customers_basket_id . "'");
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP . " where customers_basket_id = '" . $customers_basket_id . "'");
		} else {
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET . " where customers_basket_id = '" . $customers_basket_id . "'");
			hhg_db_query("delete from " . TABLE_MS_CUSTOMERS_BASKET_OPTIONS . " where customers_basket_id = '" . $customers_basket_id . "'");
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function cleanup_cart()
	{
		$cleanup_query = "
			SELECT
				customers_basket_id
			FROM
				" . TABLE_MS_CUSTOMERS_BASKET_TMP . "
			WHERE
				customers_basket_date_added < " . date('Ymd', time() - get_cfg_var('session.gc_maxlifetime')) . "
		";
		$cleanup = hhg_db_query($cleanup_query);
		if ($cleanup->RecordCount()) {
			while (!$cleanup->EOF) {
				hhg_db_query("DELETE FROM " . TABLE_MS_CUSTOMERS_BASKET_TMP . " WHERE customers_basket_id = '" . $cleanup->fields['customers_basket_id'] . "'");
				hhg_db_query("DELETE FROM " . TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP . " WHERE customers_basket_id = '" . $cleanup->fields['customers_basket_id'] . "'");
				$cleanup->MoveNext();
			}
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_products($tmp_store_id = STORE_ID, $tmp_owner = null)
	{
		global $xtPrice, $shipping_status;
		$store_qry = $this->get_store_filter($tmp_store_id, $tmp_owner);
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$products_query = "
				SELECT
					customers_basket_id,
					products_id,
					products_model,
					products_owner,
					products_alternate_name,
					products_alternate_desc,
					products_price,
					products_price_ek,
					products_tax_class,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime,
					store_id
				FROM
					" . $basket_table . "
				WHERE
					customers_id = '" . $_SESSION['customer_id'] . "'
					" . $store_qry . "
			";
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$products_query = "
				SELECT
					customers_basket_id,
					sid,
					products_id,
					products_model,
					products_owner,
					products_alternate_name,
					products_alternate_desc,
					products_price,
					products_price_ek,
					products_tax_class,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime,
					store_id
				FROM
					" . $basket_table . "
				WHERE
					sid = '" . $sid . "'
					" . $store_qry . "
			";
		}
		$products = hhg_db_query($products_query);
		while (!$products->EOF) {
			$total_price = 0;
			$price_ek = 0;
			$_options = $this->get_product_options($products->fields['customers_basket_id'], $products->fields['products_id']);
			$base_price = $xtPrice->xtcGetPrice($products->fields['products_id'], false, $products->fields['products_quantity'], $products->fields['products_tax_class'], '');
			
			$weight = $products->fields['products_weight'];
			
			if ($_options != false) {
			    $total_price = $xtPrice->xtcFormat($products->fields['products_price'], false, $products->fields['products_tax_class'], '', '', $products->fields['products_id']);
			    $price_ek = $products->fields['products_price_ek'];
			    $weight = $products->fields['products_weight'];
			    foreach($_options as $_option_product) {
			        $total_price+= $xtPrice->xtcGetPrice($_option_product['products_id'], false, '', $_option_product['products_tax_class'], $_option_product['product_raw_price']);
			        $price_ek+= $_option_product['products_price_ek'];
			        $weight+= $_option_product['products_weight'];
			    }
			    $_total_price = $xtPrice->xtcFormat($total_price, true);
			} else {
			    $total_price = $xtPrice->xtcFormat($products->fields['products_price'], false, $products->fields['products_tax_class'], '', '', $products->fields['products_id']);
			    $_total_price = $base_price;
			    $_total_price = $xtPrice->xtcFormat($total_price, true);
			    $price_ek = $products->fields['products_price_ek'];
			    $weight = $products->fields['products_weight'];
			}
			
			// einzelpreis - formatiert
			$base_price = $xtPrice->xtcFormat($base_price, true);
			$price_ek = $xtPrice->xtcFormat($price_ek, false, $products->fields['products_tax_class']) * $products->fields['products_quantity'];
			// gesamtpreis - raw
			$final_price = $products->fields['products_quantity'] * $total_price;
			// gesamtpreis - formatiert
			$_final_price = $xtPrice->xtcFormat($final_price, true);
			$name = hhg_get_products_name($products->fields['products_id'], $_SESSION['languages_id']);
			$_shipping_name = $shipping_status->getShippingStatusName($products->fields['products_shippingtime']);
			if (HHG_MS_SEO_URLS == 'true') {
				$url_text_query = hhg_db_query("SELECT url_text from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $products->fields['products_id'] . "' AND language_id = '" . $_SESSION['languages_id'] . "'");
				$url_text = $url_text_query->fields['url_text'];
			} else {
				$url_text = '';
			}
			$products_array[] = array(
				'cart_id' => $products->fields['customers_basket_id'],
				'id' => $products->fields['products_id'],
				'owner' => $products->fields['products_owner'],
				'name' => $name,
				'model' => $products->fields['products_model'],
				'price' => $base_price,
				'products_price_ek' => $price_ek,
				'quantity' => $products->fields['products_quantity'],
				'weight' => $weight,
				'total_price' => $_total_price,
				'final_price' => $_final_price,
				'raw_price' => $total_price,
				'raw_final_price' => $final_price,
				'tax_class_id' => $products->fields['products_tax_class'],
				'store_id' => $products->fields['store_id'],
				'shipping_time' => $_shipping_name,
				'url_text' => $url_text
			);
			$products->MoveNext();
		}
		return $products_array;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------------------------------------
	function get_product_options($cart_id, $products_id)
	{
		global $xtPrice, $shipping_status;
		$option_array = array();
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$basket_options_table = TABLE_MS_CUSTOMERS_BASKET_OPTIONS;
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$basket_options_table = TABLE_MS_CUSTOMERS_BASKET_OPTIONS_TMP;
		} // customer_id CHECK end
		$_options_qry = "
			SELECT
				cbo.option_id,
				cbo.option_categ,
				cbo.store_id,
				cb.products_quantity
			FROM
				" . $basket_options_table . " AS cbo,
				" . $basket_table . " AS cb
			WHERE
				cbo.customers_basket_id = '" . $cart_id . "'
				AND cbo.customers_basket_id = cb.customers_basket_id
				AND cbo.products_id = '" . $products_id . "'
		";
		$_options = hhg_db_query($_options_qry);
		if ($_options->RecordCount() > 0) {
			while (!$_options->EOF) {
				$_product = new product($_options->fields['option_id']);
				if (STOCK_CHECK == 'true') {
					$mark_stock = hhg_check_stock($_product->data['products_id'], $_options->fields['products_quantity'], $_options->fields['store_id']);
					if ($mark_stock) {
						$_SESSION['any_out_of_stock' . $_options->fields['store_id'] . ''] = 1;
					} else {
						$_SESSION['any_out_of_stock' . $_options->fields['store_id'] . ''] = 0;
					}
				}
				if (HHG_MS_SEO_URLS == 'true') {
					$url_text_query = hhg_db_query("SELECT url_text from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $_product->data['products_id'] . "' AND language_id = '" . $_SESSION['languages_id'] . "'");
					$url_text = $url_text_query->fields['url_text'];
				} else {
					$url_text = '';
				}
				$unit_price_raw = $xtPrice->xtcGetPrice($_product->pID, false, $_options->fields['products_quantity'], $_product->data['products_tax_class_id']);
				$unit_price = $xtPrice->xtcFormat($unit_price_raw, true);
				$option_array[] = array(
					'products_id' => $_options->fields['option_id'],
					'products_name' => $_product->data['products_name'],
					'OUT_OF_STOCK_MARK' => $mark_stock,
					'product_raw_price' => $_product->data['products_price'],
					'products_tax_class' => $_product->data['products_tax_class_id'],
					'products_price' => $unit_price,
					'products_price_ek' => $_product->data['products_price_ek'],
					'products_owner' => $_product->data['products_owner'],
					'products_model' => $_product->data['products_model'],
					'products_weight' => $_product->data['products_weight'],
					'products_tax_class_id' => $_product->data['products_tax_class_id'],
					'store_id' => $_options->fields['store_id'],
					'shipping_time' => $shipping_status->getShippingStatusName($_product->data['products_shippingtime']) ,
					'url_text' => $url_text
				);
				$_options->MoveNext();
			}
			return $option_array;
		}
		return false;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	//------------------------------------------------------------------------------------------------------------------------------
	function count_contents($tmp_store_id = STORE_ID)
	{
		// get total number of items in cart
		$store_qry = $this->get_store_filter($tmp_store_id);
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$cart_query = "
				SELECT
					products_id,
					products_quantity
				FROM
					" . $basket_table . "
	    						WHERE
					customers_id = '" . $_SESSION['customer_id'] . "'
					" . $store_qry . "
			";
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$cart_query = "
				SELECT
					products_id,
					products_quantity
				FROM
					" . $basket_table . "
	    						WHERE
					sid = '" . $sid . "'
					" . $store_qry . "
			";
		}
		$total_items = 0;
		$cart = hhg_db_query($cart_query);
		while (!$cart->EOF) {
			$total_items+= $cart->fields['products_quantity'];
			$cart->MoveNext();
		}
		return $total_items;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_quantity($products_id, $tmp_store_id = STORE_ID)
	{
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$product = hhg_db_query("select products_id, products_quantity from " . $basket_table . " where products_id='" . $products_id . "' and customers_id = '" . $_SESSION['customer_id'] . "' and store_id = '" . $tmp_store_id . "'");
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$product = hhg_db_query("select products_id, products_quantity from " . $basket_table . " where products_id='" . $products_id . "' and sid = '" . $sid . "' and store_id = '" . $tmp_store_id . "'");
		}
		return $product->fields['products_quantity'];
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function in_cart($products_id, $tmp_store_id = STORE_ID)
	{
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$product = hhg_db_query("select products_id from " . $basket_table . " where products_id='" . $products_id . "' and customers_id = '" . $_SESSION['customer_id'] . "' and store_id = '" . $tmp_store_id . "'");
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$product = hhg_db_query("select products_id from " . $basket_table . " where products_id='" . $products_id . "' and sid = '" . $sid . "' and store_id = '" . $tmp_store_id . "'");
		}
		if ($product->RecordCount()) {
			return true;
		} else {
			return false;
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_product_id_list($tmp_store_id = STORE_ID)
	{
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$products = hhg_db_query("select products_id from " . $basket_table . " where customers_id = '" . $_SESSION['customer_id'] . "' and store_id = '" . $tmp_store_id . "'");
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$products = hhg_db_query("select products_id from " . $basket_table . " where sid = '" . $sid . "' and store_id = '" . $tmp_store_id . "'");
		}
		$product_id_list = '';
		while (!$products->EOF) {
			$product_id_list.= ', ' . $products->fields['products_id'];
			$products->MoveNext();
		}
		return substr($product_id_list, 2);
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function calculate($tmp_store_id = STORE_ID, $tmp_owner = '')
	{
		global $xtPrice;
		$this->total = 0;
		$this->weight = 0;
		$this->tax = array();
		$store_qry = $this->get_store_filter($tmp_store_id, $tmp_owner);
		if (isset($_SESSION['customer_id'])) {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET;
			$product_query = "
				SELECT
					customers_basket_id,
					products_id,
					products_model,
					products_owner,
					products_alternate_name,
					products_alternate_desc,
					products_price,
					products_price_ek,
					products_tax_class,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime
				FROM
					" . $basket_table . "
				WHERE
					customers_id = '" . $_SESSION['customer_id'] . "'
					" . $store_qry . "
			";
		} else {
			$basket_table = TABLE_MS_CUSTOMERS_BASKET_TMP;
			$sid = session_id();
			$product_query = "
				SELECT
					customers_basket_id,
					sid,
					products_id,
					products_model,
					products_owner,
					products_alternate_name,
					products_alternate_desc,
					products_price,
					products_price_ek,
					products_tax_class,
					products_quantity,
					products_final_price,
					products_weight,
					products_shippingtime
				FROM
					" . $basket_table . "
				WHERE
					sid = '" . $sid . "'
					" . $store_qry . "
			";
		}
		$product = hhg_db_query($product_query);
		while (!$product->EOF) {
			$qty = $product->fields['products_quantity'];
			$_options = $this->get_product_options($product->fields['customers_basket_id'], $product->fields['products_id']);
			
			
			if ($_options != false) {
			    $total_price = $xtPrice->xtcFormat($product->fields['products_price'], false, $product->fields['products_tax_class'], '', '', $product->fields['products_id']);
			    $weight = $product->fields['products_weight'];
			    foreach($_options as $_option_product) {
			        $total_price+= $xtPrice->xtcGetPrice($_option_product['products_id'], false, '', $_option_product['products_tax_class'], $_option_product['product_raw_price']);
			        $weight+= $_option_product['products_weight'];
			    }
			} else {
			    $total_price = $xtPrice->xtcFormat($product->fields['products_price'], false, $product->fields['products_tax_class'], '', '', $product->fields['products_id']);
			    $weight = $product->fields['products_weight'];
			}
			$products_price = $total_price;
			$this->total+= $products_price * $qty;
			$this->weight+= ($qty * $weight);
			
			if ($product->fields['products_tax_class'] != 0) {
				if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
					$products_price_tax = $products_price - ($products_price / 100 * $_SESSION['customers_status']['customers_status_ot_discount']);
				}
				$products_tax = $xtPrice->TAX[$product->fields['products_tax_class']];
				$products_tax_description = hhg_get_tax_description($product->fields['products_tax_class']);
				// price incl tax
				if ($_SESSION['customers_status']['customers_status_show_price_tax'] == '1') {
					if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
						$this->tax[$product->fields['products_tax_class']]['value']+= ((($products_price_tax) / (100 + $products_tax)) * $products_tax) * $qty;
						$this->tax[$product->fields['products_tax_class']]['desc'] = TAX_ADD_TAX . "$products_tax_description";
					} else {
						$this->tax[$product->fields['products_tax_class']]['value']+= ((($products_price) / (100 + $products_tax)) * $products_tax) * $qty;
						$this->tax[$product->fields['products_tax_class']]['desc'] = TAX_ADD_TAX . "$products_tax_description";
					}
				}
				// excl tax + tax at checkout
				if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
					if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) {
						$this->tax[$product->fields['products_tax_class']]['value']+= (($products_price_tax) / 100) * ($products_tax) * $qty;
						$this->total+= (($products_price_tax) / 100) * ($products_tax) * $qty;
						$this->tax[$product->fields['products_tax_class']]['desc'] = TAX_NO_TAX . "$products_tax_description";
					} else {
						$this->tax[$product->fields['products_tax_class']]['value']+= (($products_price) / 100) * ($products_tax) * $qty;
						$this->total+= (($products_price) / 100) * ($products_tax) * $qty;
						$this->tax[$product->fields['products_tax_class']]['desc'] = TAX_NO_TAX . "$products_tax_description";
					}
				}
			}
			$product->MoveNext();
		}
		$this->get_content_type();
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function generate_cart_id($length = 5)
	{
		return hhg_create_random_value($length, 'digits');
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function show_total($tmp_store_id = STORE_ID, $tmp_owner = '')
	{
		$this->calculate($tmp_store_id, $tmp_owner);
		return $this->total;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function show_weight($tmp_store_id = STORE_ID, $tmp_owner = '')
	{
		$this->calculate($tmp_store_id, $tmp_owner);
		return $this->weight;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function show_tax($format = true, $tmp_store_id = STORE_ID, $tmp_owner = '')
	{
		global $xtPrice;
		$this->calculate($tmp_owner, '');
		$output = "";
		$val = 0;
		foreach($this->tax as $key => $value) {
			if ($this->tax[$key]['value'] > 0) {
				$output.= $this->tax[$key]['desc'] . ": " . $xtPrice->xtcFormat($this->tax[$key]['value'], true) . "<br />";
				$val = $this->tax[$key]['value'];
			}
		}
		if ($format) {
			return $output;
		} else {
			return $val;
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_content_type()
	{
		$this->content_type = false;
		$this->content_type = 'physical';
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function reset($reset_database = false, $tmp_store_id = '')
	{
		if ($tmp_store_id != '') {
			$store_qry = $this->get_store_filter($tmp_store_id);
		}
		$this->contents = array();
		$this->total = 0;
		$this->weight = 0;
		$this->content_type = false;
		if (isset($_SESSION['customer_id']) && ($reset_database == true)) {
			hhg_db_query("
				DELETE
				FROM
					" . TABLE_MS_CUSTOMERS_BASKET . "
				WHERE
					customers_id = '" . $_SESSION['customer_id'] . "'
					" . $store_qry . "
			");
		}
		unset($this->cartID);
		if (isset($_SESSION['cartID'])) unset($_SESSION['cartID']);
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_owner($tmp_store_id = STORE_ID)
	{
		if (USE_SINGLE_SESSIONS == 'false' && (USE_SINGLE_CHECKOUT == 'true' || USE_SINGLE_STORE_CHECKOUT == 'true')) {
			if (USE_SINGLE_CHECKOUT == 'false' && USE_SINGLE_STORE_CHECKOUT == 'true') {
				$column = 'store_id';
			} elseif (USE_SINGLE_CHECKOUT == 'true' && USE_SINGLE_STORE_CHECKOUT == 'false') {
				$column = 'products_owner';
			}
			// Warenkörbe zusammen
			if (isset($_SESSION['customer_id'])) {
				$owner_query = "
                	SELECT DISTINCT
                		" . $column . "
                	FROM
                		" . TABLE_MS_CUSTOMERS_BASKET . "
                	WHERE
                		customers_id = '" . $_SESSION['customer_id'] . "'
                ";
			} else {
				$sid = session_id();
				$owner_query = "
                	SELECT DISTINCT
                		" . $column . "
                	FROM
                		" . TABLE_MS_CUSTOMERS_BASKET_TMP . "
                	WHERE
                		sid = '" . $sid . "'
                ";
			}
			$owner = hhg_db_query($owner_query);
			while (!$owner->EOF) {
				$store_name = hhg_get_store_name($owner->fields[$column]);
				$owner_array[] = array(
					'id' => $owner->fields[$column],
					'text' => $store_name
				);
				$owner->MoveNext();
			}
			return $owner_array;
		} else {
			// Warenkörbe getrennt
			$store_name = hhg_get_store_name($tmp_store_id);
			$owner_array[] = array(
				'id' => $tmp_store_id,
				'text' => $store_name
			);
			return $owner_array;
		}
	}
	//------------------------------------------------------------------------------------------------------------------------------
	function get_store_filter($tmp_store_id = STORE_ID, $tmp_owner = null)
	{
		$store_qry = '';
		$shopping_malls = explode(';', SHOPPING_MALLS);
		if (in_array($tmp_store_id, $shopping_malls)) {
			if (USE_SINGLE_SESSIONS == 'false') {
				if (USE_SINGLE_CHECKOUT == 'true' && USE_SINGLE_STORE_CHECKOUT == 'false') {
					if (!empty($tmp_owner)) {
						$store_qry.= " AND products_owner = " . (int)$tmp_owner . " ";
					} else {
						$store_qry.= " AND products_owner = " . (int)$tmp_store_id . " ";
					}
				} elseif (USE_SINGLE_CHECKOUT == 'false' && USE_SINGLE_STORE_CHECKOUT == 'true') {
					$store_qry.= " AND store_id = " . (int)$tmp_store_id . " ";
				} elseif (USE_SINGLE_CHECKOUT == 'false' && USE_SINGLE_STORE_CHECKOUT == 'false') {
					$store_qry.= " AND store_id IN (" . implode(',', $shopping_malls) . ") ";
				}
			} else {
				if (USE_SINGLE_CHECKOUT == 'true' && USE_SINGLE_STORE_CHECKOUT == 'false') {
					if (!empty($tmp_owner)) {
						$store_qry.= " AND products_owner = " . (int)$tmp_owner . " ";
					} else {
						$store_qry.= " AND products_owner = " . (int)$_SESSION['actual_store'] . " ";
					}
					$store_qry.= " AND store_id = " . (int)$_SESSION['actual_store'] . " ";
				} elseif (USE_SINGLE_CHECKOUT == 'false' && USE_SINGLE_STORE_CHECKOUT == 'true') {
					$store_qry.= " AND store_id = " . (int)$_SESSION['actual_store'] . " ";
				} else {
					$store_qry.= '';
				}
			}
		} else {
			$store_qry = " AND store_id = '" . $tmp_store_id . "'";
		}
		return $store_qry;
	}
	//------------------------------------------------------------------------------------------------------------------------------
	
}
?>

14.01.2014 12:29