Ich habe die Staffelpreisanzeige in die Artikelübersicht (product_listing) eingebaut, mit Hilfe der Anleitung von Ralf Griep:
Staffelpreise in der ArtikelübersichtDie Grundpreisanzeige (VPE) für Staffelpreise in der Produktansicht (product_info) funktioniert wunderbar aber leider nicht in der Artikelübersicht. Dort ist der VPE preis für alle Staffelungen gleich!
Hier die Artikelansicht (product_info):
[ Für Gäste sind keine Dateianhänge sichtbar ]
Hier der gleiche Artikel in der Artikelübersicht:
[ Für Gäste sind keine Dateianhänge sichtbar ]
Ich verwende xt:Commerce 3.04 SP2.1 welches in der Vergangenheit einige Modifikationen erleiden musste.
Ich habe mir die "product.php" rauf und runter angesehen, verglichen mit anderen Versionen und versucht Parts die für die VPE und Staffelpreise zuständing sind auszutauschen, aber leider alles ohne Erfolg.
Ich hoffe das jemand den Fehler erkennen kann
"/includes/classes/product.php"
<?php/* -----------------------------------------------------------------------------------------
$Id: product.php 1316 2005-10-21 15:30:58Z mz $
XT-Commerce - community made shopping
http://www.(( Wir dulden keine kommerziellen Werbelinks - Bitte Forenregeln beachten! ))
Copyright (c) 2005 XT-Commerce
-----------------------------------------------------------------------------------------
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce(Coding Standards); www.oscommerce.com
Released under the GNU General Public License
---------------------------------------------------------------------------------------*/class product
{ /**
*
* Constructor
*
*/ function product
($pID = 0) { $this->pID = $pID; $this->useStandardImage=false; $this->standardImage='noimage.gif'; if ($pID = 0) { $this->isProduct = false; return; } // query for Product $group_check = ""; if (GROUP_CHECK
== 'true') { $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 "; } $fsk_lock = ""; if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') { $fsk_lock = ' and p.products_fsk18!=1'; } $product_query = "select * FROM ".TABLE_PRODUCTS
." p,
".TABLE_PRODUCTS_DESCRIPTION
." pd
where p.products_status = '1'
and p.products_id = '".$this->pID."'
and pd.products_id = p.products_id
".$group_check.$fsk_lock."
and pd.language_id = '".(int
) $_SESSION['languages_id']."'"; $product_query = xtDBquery
($product_query); if (!xtc_db_num_rows
($product_query, true)) { $this->isProduct = false; } else { $this->isProduct = true; $this->data = xtc_db_fetch_array
($product_query, true); } } /**
*
* Query for attributes count
*
*/ function getAttributesCount
() { $products_attributes_query = xtDBquery
("select count(*) as total from ".TABLE_PRODUCTS_OPTIONS
." popt, ".TABLE_PRODUCTS_ATTRIBUTES
." patrib where patrib.products_id='".$this->pID."' and patrib.options_id = popt.products_options_id and popt.language_id = '".(int
) $_SESSION['languages_id']."'"); $products_attributes = xtc_db_fetch_array
($products_attributes_query, true); return $products_attributes['total']; } /**
*
* Query for reviews count
*
*/ function getReviewsCount
() { $reviews_query = xtDBquery
("select count(*) as total from ".TABLE_REVIEWS
." r, ".TABLE_REVIEWS_DESCRIPTION
." rd where r.products_id = '".$this->pID."' and r.reviews_id = rd.reviews_id and rd.languages_id = '".$_SESSION['languages_id']."' and rd.reviews_text !=''"); $reviews = xtc_db_fetch_array
($reviews_query, true); return $reviews['total']; } /**
*
* select reviews
*
*/ function getReviews
() { $data_reviews = array (); $reviews_query = xtDBquery
("select
r.reviews_rating,
r.reviews_id,
r.customers_name,
r.date_added,
r.last_modified,
r.reviews_read,
rd.reviews_text
from ".TABLE_REVIEWS
." r,
".TABLE_REVIEWS_DESCRIPTION
." rd
where r.products_id = '".$this->pID."'
and r.reviews_id=rd.reviews_id
and rd.languages_id = '".$_SESSION['languages_id']."'
order by reviews_id DESC"); if (xtc_db_num_rows
($reviews_query, true)) { $row = 0; $data_reviews = array (); while ($reviews = xtc_db_fetch_array
($reviews_query, true)) { $row ++; $data_reviews[] = array ('AUTHOR' => $reviews['customers_name'], 'DATE' => xtc_date_short
($reviews['date_added']), 'RATING' => xtc_image
('templates/'.CURRENT_TEMPLATE
.'/img/stars_'.$reviews['reviews_rating'].'.gif', sprintf(TEXT_OF_5_STARS
, $reviews['reviews_rating'])), 'TEXT' => $reviews['reviews_text']); if ($row == PRODUCT_REVIEWS_VIEW
) break; } } return $data_reviews; } /**
*
* return model if set, else return name
*
*/ function getBreadcrumbModel
() { return $this->data['products_name']; } /**
*
* get also purchased products related to current
*
*/ function getAlsoPurchased
() { global $xtPrice; $module_content = array (); $fsk_lock = ""; if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') { $fsk_lock = ' and p.products_fsk18!=1'; } $group_check = ""; if (GROUP_CHECK
== 'true') { $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 "; } $orders_query = "select
p.products_fsk18,
p.products_id,
p.products_price,
p.products_tax_class_id,
p.products_image,
pd.products_name,
p.products_vpe,
p.products_vpe_status,
p.products_vpe_value,
pd.products_short_description FROM ".TABLE_ORDERS_PRODUCTS
." opa, ".TABLE_ORDERS_PRODUCTS
." opb, ".TABLE_ORDERS
." o, ".TABLE_PRODUCTS
." p, ".TABLE_PRODUCTS_DESCRIPTION
." pd
where opa.products_id = '".$this->pID."'
and opa.orders_id = opb.orders_id
and opb.products_id != '".$this->pID."'
and opb.products_id = p.products_id
and opb.orders_id = o.orders_id
and p.products_status = '1'
and pd.language_id = '".(int
) $_SESSION['languages_id']."'
and opb.products_id = pd.products_id
".$group_check."
".$fsk_lock."
group by p.products_id order by o.date_purchased desc limit ".MAX_DISPLAY_ALSO_PURCHASED
; $orders_query = xtDBquery
($orders_query); while ($orders = xtc_db_fetch_array
($orders_query, true)) { $module_content[] = $this->buildDataArray($orders); } return $module_content; } /**
*
*
* Get Cross sells
*
*
*/ function getCrossSells
() { global $xtPrice; $cs_groups = "SELECT products_xsell_grp_name_id FROM ".TABLE_PRODUCTS_XSELL
." WHERE products_id = '".$this->pID."' GROUP BY products_xsell_grp_name_id"; $cs_groups = xtDBquery
($cs_groups); $cross_sell_data = array (); if (xtc_db_num_rows
($cs_groups, true)>0) { while ($cross_sells = xtc_db_fetch_array
($cs_groups, true)) { $fsk_lock = ''; if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') { $fsk_lock = ' and p.products_fsk18!=1'; } $group_check = ""; if (GROUP_CHECK
== 'true') { $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 "; } $cross_query = "select p.products_fsk18,
p.products_tax_class_id,
p.products_id,
p.products_image,
pd.products_name,
pd.products_short_description,
p.products_fsk18,p.products_price,p.products_vpe,
p.products_vpe_status,
p.products_vpe_value,
xp.sort_order from ".TABLE_PRODUCTS_XSELL
." xp, ".TABLE_PRODUCTS
." p, ".TABLE_PRODUCTS_DESCRIPTION
." pd
where xp.products_id = '".$this->pID."' and xp.xsell_id = p.products_id ".$fsk_lock.$group_check."
and p.products_id = pd.products_id and xp.products_xsell_grp_name_id='".$cross_sells['products_xsell_grp_name_id']."'
and pd.language_id = '".$_SESSION['languages_id']."'
and p.products_status = '1'
order by xp.sort_order asc"; $cross_query = xtDBquery
($cross_query); if (xtc_db_num_rows
($cross_query, true) > 0) $cross_sell_data[$cross_sells['products_xsell_grp_name_id']] = array ('GROUP' => xtc_get_cross_sell_name
($cross_sells['products_xsell_grp_name_id']), 'PRODUCTS' => array ()); while ($xsell = xtc_db_fetch_array
($cross_query, true)) { $cross_sell_data[$cross_sells['products_xsell_grp_name_id']]['PRODUCTS'][] = $this->buildDataArray($xsell); } } return $cross_sell_data; } } /**
*
* get reverse cross sells
*
*/ function getReverseCrossSells
() { global $xtPrice; $fsk_lock = ''; if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') { $fsk_lock = ' and p.products_fsk18!=1'; } $group_check = ""; if (GROUP_CHECK
== 'true') { $group_check = " and p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 "; } $cross_query = xtDBquery
("select p.products_fsk18,
p.products_tax_class_id,
p.products_id,
p.products_image,
pd.products_name,
pd.products_short_description,
p.products_fsk18,p.products_price,p.products_vpe,
p.products_vpe_status,
p.products_vpe_value,
xp.sort_order from ".TABLE_PRODUCTS_XSELL
." xp, ".TABLE_PRODUCTS
." p, ".TABLE_PRODUCTS_DESCRIPTION
." pd
where xp.xsell_id = '".$this->pID."' and xp.products_id = p.products_id ".$fsk_lock.$group_check."
and p.products_id = pd.products_id
and pd.language_id = '".$_SESSION['languages_id']."'
and p.products_status = '1'
order by xp.sort_order asc"); while ($xsell = xtc_db_fetch_array
($cross_query, true)) { $cross_sell_data[] = $this->buildDataArray($xsell); } return $cross_sell_data; } function getGraduated
() { global $xtPrice; $staffel_query = xtDBquery
("SELECT
quantity,
personal_offer
FROM
".TABLE_PERSONAL_OFFERS_BY
.(int
) $_SESSION['customers_status']['customers_status_id']."
WHERE
products_id = '".$this->pID."'
ORDER BY quantity ASC"); $discount = $xtPrice->xtcCheckDiscount($this->pID); //EINGEFÜGT! $staffel = array (); while ($staffel_values = xtc_db_fetch_array
($staffel_query, true)) { $staffel[] = array ('stk' => $staffel_values['quantity'], 'price' => $staffel_values['personal_offer']); } $staffel_data = array (); for ($i = 0, $n = sizeof($staffel); $i < $n; $i ++) { if ($staffel[$i]['stk'] == 1) { $quantity = $staffel[$i]['stk']; if ($staffel[$i +1]['stk'] != '') $quantity = $staffel[$i]['stk'].'-'. ($staffel[$i +1]['stk'] - 1); } else { $quantity = ' > '.$staffel[$i]['stk']; if ($staffel[$i +1]['stk'] != '') $quantity = $staffel[$i]['stk'].'-'. ($staffel[$i +1]['stk'] - 1); } $vpe = ''; if ($this->data['products_vpe_status'] == 1 && $this->data['products_vpe_value'] != 0.0 && $staffel[$i]['price']> 0) { $vpe = $staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount; $vpe = $vpe * (1 / $this->data['products_vpe_value']); $vpe = $xtPrice->xtcFormat($vpe, true, $this->data['products_tax_class_id']).TXT_PER
.xtc_get_vpe_name
($this->data['products_vpe']); } $staffel_data[$i] = array ('QUANTITY' => $quantity, 'VPE' => $vpe, 'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount, true, $this->data['products_tax_class_id'])); } return $staffel_data; } /**
*
* valid flag
*
*/ function isProduct
() { return $this->isProduct; } // beta function getBuyNowButton
($id, $name) { global $PHP_SELF; return '<a href="'.xtc_href_link
(basename($PHP_SELF), 'action=buy_now&BUYproducts_id='.$id.'&'.xtc_get_all_get_params
(array ('action')), 'NONSSL').'">'.xtc_image_button
('button_buy_now.gif', TEXT_BUY
.$name.TEXT_NOW
).'</a>'; } function getVPEtext
($product, $price) { global $xtPrice; require_once (DIR_FS_INC
.'xtc_get_vpe_name.inc.php'); if (!is_array($product)) $product = $this->data; if ($product['products_vpe_status'] == 1 && $product['products_vpe_value'] != 0.0 && $price > 0) { return $xtPrice->xtcFormat($price * (1 / $product['products_vpe_value']), true).TXT_PER
.xtc_get_vpe_name
($product['products_vpe']); } return; } function buildDataArray
(&$array,$image='thumbnail') { global $xtPrice,$main; $tax_rate = $xtPrice->TAX[$array['products_tax_class_id']]; $products_price = $xtPrice->xtcGetPrice($array['products_id'], $format = true, 1, $array['products_tax_class_id'], $array['products_price'], 1); if ($_SESSION['customers_status']['customers_status_show_price'] != '0') { if ($_SESSION['customers_status']['customers_fsk18'] == '1') { if ($array['products_fsk18'] == '0') $buy_now = $this->getBuyNowButton($array['products_id'], $array['products_name']); } else { $buy_now = $this->getBuyNowButton($array['products_id'], $array['products_name']); } } // mindesbestellmenge $min_qty = 1; $min_qty_text = ''; if($array['products_min_quantity'] != 0) { $min_qty = $array['products_min_quantity']; $min_qty_text = TEXT_PRODUCTS_MIN_QTY
.$min_qty.' '.xtc_get_vpe_name
($array['products_min_quantity_value']); } $shipping_status_name = $main->getShippingStatusName($array['products_shippingtime']); $shipping_status_image = $main->getShippingStatusImage($array['products_shippingtime']); // Hersteller abfragen $manufacturer_query = xtc_db_query
("select m.manufacturers_id,
m.manufacturers_name,
m.manufacturers_image,
mi.manufacturers_url
from " . TABLE_MANUFACTURERS
. " m
left join " . TABLE_MANUFACTURERS_INFO
. " mi
on (m.manufacturers_id = mi.manufacturers_id and
mi.languages_id = '" . (int
)$_SESSION['languages_id'] . "'),
" . TABLE_PRODUCTS
. " p
where p.products_id = '" . $array['products_id'] . "'
and p.manufacturers_id = m.manufacturers_id"); $manufacturer = xtc_db_fetch_array
($manufacturer_query);// Hersteller abfragen ende$special_status_query = xtc_db_query
("select
s.status,
s.products_id
from " . TABLE_SPECIALS
. " s where products_id = '".$array['products_id']."'"); $special_status = xtc_db_fetch_array
($special_status_query); // staffelpreise ab hier komplette funktion getGraduated $staffelda = $_SESSION['customers_status']['customers_status_graduated_prices']; $products_rabatt= $xtPrice->xtcCheckDiscount($array['products_id']); $staffel_query = xtDBquery
("SELECT
quantity,
personal_offer
FROM
".TABLE_PERSONAL_OFFERS_BY
.(int
) $_SESSION['customers_status']['customers_status_id']."
WHERE
products_id = '".$array['products_id']."'
ORDER BY quantity ASC"); //products_id = '".$array['products_id']."' Wert geŠndert // alt '".$this->pID."' $staffel = array (); while ($staffel_values = xtc_db_fetch_array
($staffel_query, true)) { $staffel[] = array ('stk' => $staffel_values['quantity'], 'price' => $staffel_values['personal_offer']); } $staffel_data = array (); for ($i = 0, $n = sizeof($staffel); $i < $n; $i ++) { if ($staffel[$i]['stk'] == 1) { $quantity = $staffel[$i]['stk']; if ($staffel[$i +1]['stk'] != '') $quantity = $staffel[$i]['stk'].'-'. ($staffel[$i +1]['stk'] - 1); } else { $quantity = ' > '.$staffel[$i]['stk']; if ($staffel[$i +1]['stk'] != '') $quantity = $staffel[$i]['stk'].'-'. ($staffel[$i +1]['stk'] - 1); } $vpe = ''; if ($product_info['products_vpe_status'] == 1 && $product_info['products_vpe_value'] != 0.0 && $staffel[$i]['price'] > 0) { $vpe = $staffel[$i]['price'] - $staffel[$i]['price'] / 100 * $discount; $vpe = $vpe * (1 / $product_info['products_vpe_value']); $vpe = $xtPrice->xtcFormat($vpe, true, $product_info['products_tax_class_id']).TXT_PER
.xtc_get_vpe_name
($product_info['products_vpe']); } //$staffel_data[$i] = array ('QUANTITY' => $quantity, 'VPE' => $vpe, 'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] + $staffel[$i]['price'] / 100 * $tax_rate - $staffel[$i]['price'] / 100 * $discount, true, $this->data['products_tax_class_id'])); if ($_SESSION['customers_status']['customers_status_show_price_tax'] != 0) { $staffel_data[$i] = array ('RABATT' => $products_rabatt,'QUANTITY' => $quantity, 'VPE' => $vpe, 'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] * $faktor - $staffel[$i]['price'] * $faktor / 100 * $products_rabatt, + $staffel[$i]['price'] * $faktor / 100 * $tax_rate , true, $this->data['products_tax_class_id'])); }else{ $staffel_data[$i] = array ('QUANTITY' => $quantity, 'VPE' => $vpe, 'PRICE' => $xtPrice->xtcFormat($staffel[$i]['price'] * $faktor + $price - $staffel[$i]['price'] * $faktor / 100 * $products_rabatt, true, $this->data['products_tax_class_id'])); } } //echo '--->'.$products_rabatt; // bis hier return array ('PRODUCTS_NAME' => $array['products_name'], 'COUNT'=>$array['ID'],/*das dazu*/ 'STAFFELDA'=> $staffelda, 'PRODUCTS_ID'=>$array['products_id'], // added code for artikel anzahl wahl und warenkorb button 'FORM_ACTION' => xtc_href_link
(FILENAME_DEFAULT
, xtc_get_all_get_params
(array('action')) . 'action=add_product'), 'ADD_QTY' => xtc_draw_input_field
('products_qty', $min_qty,'size="3"') . ' ' . xtc_draw_hidden_field
('products_id', $array['products_id']), 'ADD_CART_BUTTON' => xtc_image_submit
('button_in_cart.gif', IMAGE_BUTTON_IN_CART
), // added code end 'PRODUCTS_VPE' => $this->getVPEtext($array, $products_price['plain']), 'PRODUCTS_IMAGE' => $this->productImage($array['products_image'], $image), 'PRODUCTS_LINK' => xtc_href_link
(FILENAME_PRODUCT_INFO
, xtc_product_link
($array['products_id'], $array['products_name'])), 'PRODUCTS_PRICE' => $products_price['formated'], 'PRODUCTS_TAX_INFO' => $main->getTaxInfo($tax_rate), 'PRODUCTS_SHIPPING_LINK' => $main->getShippingLink(), 'PRODUCTS_BUTTON_BUY_NOW' => $buy_now, 'PRODUCTS_SHIPPING_NAME'=>$shipping_status_name, 'PRODUCTS_SHIPPING_IMAGE'=>$shipping_status_image, 'PRODUCTS_DESCRIPTION' => $array['products_description'], 'PRODUCTS_MODEL' => $array['products_model'], 'PRODUCTS_ORDERED' => $array['products_ordered'], 'PRODUCTS_VIEWED' => $array['products_viewed'], 'PRODUCTS_QUANTITY' => $array['products_quantity'], 'PRODUCTS_EXPIRES' => $array['expires_date'], 'PRODUCTS_CATEGORY_URL'=>$array['cat_url'], 'PRODUCTS_SHORT_DESCRIPTION' => $array['products_short_description'], 'PRODUCTS_FSK18' => $array['products_fsk18'], 'PRODUCTS_MIN_QTY' => $min_qty_text, 'PRODUCTS_DISCOUNT' => $array['products_discount_allowed'], // Hersteller im listing anzeigen 'MAN_NAME' => $manufacturer['manufacturers_name'], 'MAN_IMAGE'=> DIR_WS_IMAGES
.$manufacturer['manufacturers_image'], 'SPECIAL_STATUS' => $special_status['status'], 'PRODUCTS_VPE_VALUE' => $array['products_vpe_value'],/*das dazu*/ 'STAFFELUNG'=> $staffel_data); } function productImage
($name, $type) { switch ($type) { case 'info' : $path = DIR_WS_INFO_IMAGES
; break; case 'thumbnail' : $path = DIR_WS_THUMBNAIL_IMAGES
; break; case 'popup' : $path = DIR_WS_POPUP_IMAGES
; break; } if ($name == '') { if ($this->useStandardImage == 'true' && $this->standardImage != '') return $path.$this->standardImage; } else { // check if image exists if (!file_exists($path.$name)) { if ($this->useStandardImage == 'true' && $this->standardImage != '') $name = $this->standardImage; } return $path.$name; } } }?> Auszug aus der "/templates/<mein-template>/module/product_listing/product_listing.html":
{if $module_data.STAFFELDA
>0} {config_load
file="$language/lang_$language.conf" section
="graduated_price"} <table width
="200" border
="0" align
="left"> <tr
> <td style
="border-bottom: 1px solid; border-color: #CCCCCC;" width
="110">Qty
: </td
> <td style
="border-bottom: 1px solid; border-color: #CCCCCC;">Price
: </td
> </tr
> {section name
=staffel loop
=$module_data.STAFFELUNG
} <tr
> <td width
="110" valign
="top" nowrap
="nowrap" class="main" style
="border-bottom: 1px solid; border-color: #CCCCCC;">{$module_data.STAFFELUNG
[staffel
].QUANTITY
}{if $module_data.PRODUCTS_VPE
} trays
{/if}</td
> <td style
="border-bottom: 1px solid; border-color: #CCCCCC;" class="main" nowrap
="nowrap"><strong
>{$module_data.STAFFELUNG
[staffel
].PRICE
}each {if $module_data.PRODUCTS_VPE
} tray
{/if} </strong
>{if $module_data.PRODUCTS_VPE
}(= {$module_data.PRODUCTS_VPE
}){/if}</td
> </tr
> {/section
} </table
> {/if} Linkback: https://www.modified-shop.org/forum/index.php?topic=15112.0