Zur Navigation

Preise ändern per PHP [2]

11 ShadowLupina

aktuell sieht der code so aus

<?php
/* --------------------------------------------------------------
$Id: product_price.php 3569 2010-01-21 14:43:47Z hhgag $


H.H.G. multistore

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

Copyright (c) 2005-2010 H.H.G. group
-----------------------------------------------------------------------------------------
based on:

(c) 2003-2005 xt:Commerce (product_price.php 1344 2005-11-14); www.xt-commerce.com

Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
defined('_VALID_HHG_MS') or die('Direct Access to this location is not allowed.');
require_once (DIR_WS_CORE_INC . 'get_proddata.inc.php');
$module_theme = new hhg_theme;
// Get Adminrights for this File:
$file_id = 30; // Rights ID from Database
$rights = $access->getFileAccess($file_id, $access->access['admin_class_id'], $access->access['admin_group_id']);
if (!$rights['admin_view']) {
	$module = $module_theme->fetch(CURRENT_THEME . '/admin/modules/error.html');
} else {
	$r_view = $rights['admin_view'];
	$r_edit = $rights['admin_edit'];
	$r_delete = $rights['admin_delete'];
	$r_new = $rights['admin_new'];
	// Admin Rights End
	if (($_GET['pID']) && (!$_POST)) {
		$product = hhg_db_query("select p.products_id, pd.products_name
	                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                                  where p.products_id = '" . (int)$_GET['pID'] . "'
                                  and p.products_id = pd.products_id
                                  and pd.language_id = '" . $_SESSION['languages_id'] . "'");
		$pInfo = new object_Info($product->fields);
	} elseif ($_POST) {
		$pInfo = new object_Info($_POST);
		$products_name = $_POST['products_name'];
	} else {
		$pInfo = new object_Info(array());
	}
	$pprice = hhg_db_query("select products_price, products_quantity, products_model, products_shippingtime, products_calculated, products_calculated_by, products_price_ek, products_tax_class_id, products_discount_allowed from " . TABLE_PRODUCTS_PRICE . " where products_id = '" . $pInfo->products_id . "' and store_id = '" . $_SESSION['actual_store'] . "'");
	$org_products_price = $pInfo->products_price;
	$org_products_price_ek = $pInfo->products_price_ek;
	$org_products_tax_class_id = $pInfo->products_tax_class_id;
	$org_products_discount_allowed = $pInfo->products_discount_allowed;
	$pInfo->products_price = $pprice->fields['products_price'];
	$pInfo->products_price_ek = $pprice->fields['products_price_ek'];
	$pInfo->products_quantity = $pprice->fields['products_quantity'];
	$pInfo->products_tax_class_id = $pprice->fields['products_tax_class_id'];
	$pInfo->products_discount_allowed = $pprice->fields['products_discount_allowed'];
	$pInfo->products_model = $pprice->fields['products_model'];
	$pInfo->products_shippingtime = $pprice->fields['products_shippingtime'];
	$pInfo->products_calculated = $pprice->fields['products_calculated'];
	$pInfo->products_calculated_by = $pprice->fields['products_calculated_by'];
	$tax_class_array = get_tax_classes();
	$shipping_statuses = get_shipping_status();
	$pcb_array = array(
		array(
			'id' => 'none',
			'text' => NONE
		) ,
		array(
			'id' => 'p',
			'text' => PRODUCT
		) ,
		array(
			'id' => 'm',
			'text' => MANUFACTURER
		) ,
		array(
			'id' => 'g',
			'text' => PRODUCT_GROUP
		)
	);
	$form_action = 'insert_product_price';
	$module_theme->assign('FORM_ACTION', hhg_draw_form('new_product', hhg_href_link(FILENAME_CATEGORIES, 'cPath=' . $_GET['cPath'] . '&pID=' . $_GET['pID'] . '&action=' . $form_action) , 'post', 'enctype="multipart/form-data"'));
	$module_theme->assign('FORM_HEADING', sprintf(TEXT_NEW_PRODUCT, xtc_output_generated_category_path($current_category_id)));
	$module_theme->assign('FORM_END', '</form>');
	$module_theme->assign('FORM_SUBMIT', '<input type="submit" class="button" onClick="this.blur();" value="' . BUTTON_SAVE . '"/>');
	$module_theme->assign('FORM_CANCEL', '<a class="button" href="' . hhg_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $_GET['pID']) . '">' . BUTTON_CANCEL . '</a>');
	$module_theme->assign('PRODUCTS_ID', hhg_draw_input_field('products_id', $pInfo->products_id));
	$module_theme->assign('PRODUCTS_QUANTITY', hhg_draw_input_field('products_quantity', $pInfo->products_quantity, 'size=5'));
	$module_theme->assign('PRODUCTS_MODEL', hhg_draw_input_field('products_model', $pInfo->products_model));
	$module_theme->assign('PRODUCTS_SHIPPING', hhg_draw_pull_down_menu('shipping_status', $shipping_statuses, $pInfo->products_shippingtime));
	$module_theme->assign('PRODUCTS_CB', hhg_draw_pull_down_menu('products_calculated_by', $pcb_array, $pInfo->products_calculated_by));
	// Price & Groupprice Anfang
	require_once (DIR_FS_CORE_INC . 'inc.hhg_get_tax_rate.php');
	$xtPrice = new xtcPrice(DEFAULT_CURRENCY, $_SESSION['customers_status']['customers_status_id']);
	$i = 0;
	$group_values = hhg_db_query("SELECT customers_status_image,
                                    customers_status_id,
                                    customers_status_name
                                    FROM
                                    " . TABLE_CUSTOMERS_STATUS . "
                                    WHERE
                                    language_id = '" . $_SESSION['languages_id'] . "' AND customers_status_id != '0'");
	while (!$group_values->EOF) {
		// load data into array
		$i++;
		$group_data[$i] = array(
			'STATUS_NAME' => $group_value->fields['customers_status_name'],
			'STATUS_IMAGE' => $group_value->fields['customers_status_image'],
			'STATUS_ID' => $group_value->fields['customers_status_id']
		);
		$group_values->MoveNext();
	}
	// Multiplier
	$multi = hhg_db_query("select multiplier from " . TABLE_PRODUCTS_CALCULATION . " where products_id = '" . $pInfo->products_id . "' and store_id = '" . $_SESSION['actual_store'] . "' ");
	$module_theme->assign('PRODUCTS_MULTIPLIER', hhg_draw_input_field('multiplier', $multi->fields['multiplier']));
	$customers_status = new customers_status();
	$customers_statuses_array = $customers_status->customersStatusList($_SESSION['actual_store']);
	foreach($customers_statuses_array as $customers_statuses) {
		$mmulti = hhg_db_query("select multiplier_" . $customers_statuses['id'] . " from " . TABLE_PRODUCTS_CALCULATION . " where products_id = '" . $pInfo->products_id . "' and store_id = '" . $_SESSION['actual_store'] . "'  ");
		$module_multi_content.= hhg_draw_input_field('multiplier_' . $customers_statuses['id'], $mmulti->fields['multiplier_' . $customers_statuses['id'] . '']) . '&nbsp;' . $customers_statuses['text'] . '<br /><br />';
	}
	$module_theme->assign('SHOW_CALCULATION', true);
	// Multiplier
	// Products Price EK Start
	$module_price_content.= '<tr class="dataTableRow">';
	$module_price_content.= '<td class="dataTableContent" align="left" width="20%">' . TEXT_PRODUCTS_PRICE_EK . '</td>';
	$module_price_content.= '<td class="dataTableContent" align="left" width="80%">';
	if (PRICE_IS_BRUTTO == 'true') {
		$products_price_ek = hhg_round($pInfo->products_price_ek * ((100 + hhg_get_tax_rate($pInfo->products_tax_class_id)) / 100) , PRICE_PRECISION);
	} else {
		$products_price_ek = hhg_round($pInfo->products_price_ek, PRICE_PRECISION);
	}
	$module_price_content.= hhg_draw_input_field('products_price_ek', $products_price_ek) . '&nbsp;';
	if (PRICE_IS_BRUTTO == 'true') {
		$module_price_content.= TEXT_NETTO . ' <b>' . $xtPrice->xtcFormat($pInfo->products_price_ek, true) . '</b>';
	}
	$module_price_content.= '</td>';
	$module_price_content.= '</tr>';
	// Products Price EK END
	// Products Price
	

	$module_price_content.= '<tr class="dataTableRow">';
	$module_price_content.= '<td class="dataTableContent" align="left" width="20%">' . TEXT_PRODUCTS_PRICE . '</td>';
	$module_price_content.= '<td class="dataTableContent" align="left" width="80%">';
	
	
		
	if (PRICE_IS_BRUTTO == 'true') {
		$products_price = hhg_round($pInfo->products_price * ((100 + hhg_get_tax_rate($pInfo->products_tax_class_id)) / 100) , PRICE_PRECISION);
	} else {
		$products_price = hhg_round($pInfo->products_price, PRICE_PRECISION);
	}
	
	
	//EinbauPreisaenderung spanischer Produkte
	
	if ($_SESSION['languages_id'] == 3){
        $products_price = $pInfo->products_price + 10;
    }
	
	//Ende
	
	$module_price_content.= hhg_draw_input_field('products_price', $products_price) . '&nbsp;';
	if (PRICE_IS_BRUTTO == 'true') {
		$module_price_content.= TEXT_NETTO . ' <b>' . $xtPrice->xtcFormat($pInfo->products_price, true) . '</b>';
	}
	

	$module_price_content.= '</td>';
	$module_price_content.= '</tr>';
	// Products Price END
	// Group Price
	for ($col = 0, $n = sizeof($group_data); $col < $n + 1; $col++) {
		if ($group_data[$col]['STATUS_NAME'] != '') {
			$module_price_content.= '<tr class="dataTableRow">';
			$module_price_content.= '<td class="dataTableContent" align="left" width="20%">' . $group_data[$col]['STATUS_NAME'] . '</td>';
			$module_price_content.= '<td class="dataTableContent" align="left" width="80%">';
			if (PRICE_IS_BRUTTO == 'true') {
				$products_price = hhg_round(get_group_price($group_data[$col]['STATUS_ID'], $pInfo->products_id, $pInfo->products_owner) * ((100 + hhg_get_tax_rate($pInfo->products_tax_class_id)) / 100) , PRICE_PRECISION);
			} else {
				$products_price = hhg_round(get_group_price($group_data[$col]['STATUS_ID'], $pInfo->products_id, $pInfo->products_owner) , PRICE_PRECISION);
			}
			$module_price_content.= hhg_draw_input_field('products_price_' . $group_data[$col]['STATUS_ID'], $products_price);
			if (PRICE_IS_BRUTTO == 'true' && get_group_price($group_data[$col]['STATUS_ID'], $pInfo->products_id, $pInfo->products_owner) != '0') {
				$module_price_content.= TEXT_NETTO . '<b>' . $xtPrice->xtcFormat(get_group_price($group_data[$col]['STATUS_ID'], $pInfo->products_id) , true) . '</b>  ';
			}
			$module_price_content.= '</td>';
			$module_price_content.= '</tr>';
		}
	}
	// Group Price END
	// Tax
	$module_price_content.= '<tr class="dataTableRow">';
	$module_price_content.= '<td class="dataTableContent" align="left" width="20%">' . TEXT_PRODUCTS_TAX_CLASS . '</td>';
	$module_price_content.= '<td class="dataTableContent" align="left" width="80%">' . hhg_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id) . '</td>';
	$module_price_content.= '</tr>';
	// Tax End
	// Discount
	$module_price_content.= '<tr class="dataTableRow">';
	$module_price_content.= '<td class="dataTableContent" align="left" width="20%">' . TEXT_PRODUCTS_DISCOUNT_ALLOWED . '</td>';
	$module_price_content.= '<td class="dataTableContent" align="left" width="80%">' . hhg_draw_input_field('products_discount_allowed', $pInfo->products_discount_allowed) . '</td>';
	$module_price_content.= '</tr>';
	// Discount End
	require_once (DIR_WS_CORE_INC . 'get_special_price.inc.php');
	$products_special = get_special_price($_SESSION['actual_store'], $pInfo->products_id);
	if (PRICE_IS_BRUTTO == 'true') {
		$products_special_price = hhg_round($products_special['specials_new_products_price'] * ((100 + hhg_get_tax_rate($pInfo->products_tax_class_id)) / 100) , PRICE_PRECISION);
	} else {
		$products_special_price = hhg_round($products_special['specials_new_products_price'], PRICE_PRECISION);
	}
	$module_theme->assign('PRODUCTS_SPECIAL_PRICE', hhg_draw_input_field('products_special_price', $products_special_price, 'size="10"'));
	$module_theme->assign('PRODUCTS_SPECIAL_QTY', hhg_draw_input_field('products_special_qty', $products_special['specials_quantity'], 'size="3"'));
	$module_theme->assign('PRODUCTS_SPECIAL_DATE', hhg_draw_input_field('products_special_date', $products_special['expires_date'], 'size="10"'));
	if (isset($products_special['status'])) {
		$spcheck = 'checked';
	}
	$module_theme->assign('PRODUCTS_SPECIAL_STATUS', hhg_draw_checkbox_field('products_special_status', '1', $spcheck));
	// Price & Groupprice END
	$module_theme->assign('HIDDEN_DATE', hhg_draw_hidden_field('products_date_added', (($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))));
	$module_theme->assign('HIDDEN_ID', hhg_draw_hidden_field('products_id', $pInfo->products_id));
	if ((SHOPPING_MALLS) && (STORE_KEY == 'b2788e1ab6be65f1c38bf7d23cd081f1')) {
		$module_theme->assign('SHOW_MALL', true);
		require_once (DIR_FS_CORE_INC . 'inc.hhg_get_store_name.php');
		$malls = explode(';', SHOPPING_MALLS);
		for ($i = 0; $n = sizeof($malls) , $i < $n; $i++) {
			$cat = hhg_db_query("SELECT categories_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = '" . $pInfo->products_id . "' and mall = '" . $malls[$i] . "'");
			$mall_name = hhg_get_store_name($malls[$i]);
			$module_mall_content.= '<b>' . $mall_name . ':</b>&nbsp;' . hhg_draw_input_field('mall_cat_' . $malls[$i] . '', $cat->fields['categories_id'], 'size="10"') . '<br>';
		}
	}
	$module_theme->assign('module_price_content', $module_price_content);
	$module_theme->assign('module_multi_content', $module_multi_content);
	$module_theme->assign('module_content', $module_content);
	$module = $module_theme->fetch(CURRENT_THEME . '/admin/modules/categories/product_price.html');
}
$theme->assign('main_content', $module);
?>

12.12.2013 17:34

12 Jörg Kruse

Lass dir $_SESSION['languages_id'] direkt ausgeben, um zu überprüfen, ob hier wirklich die erwartete Zahl enthalten ist

    echo '$_SESSION[\'languages_id\']: ' . (int) $_SESSION['languages_id'];
    if ($_SESSION['languages_id'] == 3){
        $products_price = $pInfo->products_price + 10;
    }

12.12.2013 17:47

13 ShadowLupina

Ok...habe ich gemacht...aber da würd nirgendswo was ausgegeben...wo genau müsste ich das finden?

Hier ist eine der spanischen produktseiten

http://www.mainbrick.es/shop/product/nano-sellador-de-suelos/nano-sellador-de-suelos-la-aternativa-para-los-revestimientos-exteriores.html?HHGsid=c8aa5d4fa9b0771024f60b000a87a183

13.12.2013 11:37

14 Jörg Kruse

Bist du sicher, dass du überhaupt die richtige Datei bearbeitest? was passiert denn, wenn du diese Datei (kurzfristig) umbenennst - funktioniert die Seite dann noch ordnungsgemäß?

13.12.2013 11:56

15 ShadowLupina

Zitat von Jörg
Bist du sicher, dass du überhaupt die richtige Datei bearbeitest? was passiert denn, wenn du diese Datei (kurzfristig) umbenennst - funktioniert die Seite dann noch ordnungsgemäß?

Es passiert nix...also ich kann keine Änderung feststellen...weder im Front - noch im Backend...heißt dass das die Datei gar nicht ausgeführt wird ?

13.12.2013 12:47

16 Jörg Kruse

Ja, sieht so aus.

Die Preise werden wohl in einer anderen Datei bearbeitet / ausgegeben.

13.12.2013 15:14

17 ShadowLupina

Zitat von Jörg
Ja, sieht so aus.

Die Preise werden wohl in einer anderen Datei bearbeitet / ausgegeben.

Ok danke schön....dann Frage ich mich nur welche Zweck die product_price.php dann hat, die ich versucht habe zu bearbeiten o0

13.12.2013 15:31

18 ShadowLupina

Ich denke mal eine Html Datei zu ändern...wurde ja auch nichts bringen, dass das ja nur die Art ändert was der User angezeigt bekommt..aber nicht den tatsächlichen Preis oder?

19.12.2013 10:31

19 Jörg Kruse

Die HTML-Seiten sind aber doch nicht statisch, sondern werden von PHP generiert?

Falls du durch die PHP-Dateien nicht durchsteigst, würde ich vielleicht mal im Support-Forum der Shopsoftware nachfragen, wo man zentral den Preis in Abhängigkeit eines Parameters wie der Sprache ändern kann.

Wobei, wenn ich das nochmal genauer bedenke, dies eh für eine heikle Angelegenheit halte. Es muss ja sichergestellt werden, dass der Preis durchgehend geändert wird - also in der Auszeichnung des Produkts, im Warenkorb, in Emailbestätigungen etc. Da darf man nichts übersehen, andernfalls könnten da veilleicht auch sehr leicht rechtliche Probleme entstehen! Ein Grund mehr die Leute zu fragen, die die Shopsoftware programmiert haben, wie man das am saubersten bewerkstelligen könnte.

19.12.2013 16:42

20 ShadowLupina

Hi also mir ist jetzt gesagt worden, dass in dieser Funktion

// 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)
	{
		$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);
		}
		// Normalpreis ausgabes
		if (($PriceAsImage == true) && ($format == true)) {
			return $this->xtcFormatI($pPrice, $format);
		} else {
			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;
	}

die Summe für Spanien aufadiern müsste und dann sollte es überall stimmen

bin mir jetzt allerdings unsicher welche die richtige stelle wäre...und würde hier ansetzen:

// 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);
		}


dort würde ich dann

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

einfügen

10.01.2014 13:06 | geändert: 10.01.2014 13:08