Guten Tag, beschäftige mich derzeit an einem Fix wo auf ein Artikel mit all seinen Eigenschaften rabattiert wird. Der Ribbon macht schon mal, was er soll. Mit jeder Eigenschaft errechnet er den richtigen Prozentsatz. Doch irgendwie komme ich an dem Punkt der dynamischen Gesamtpreisanzeige nicht weiter und bitte um Rat von den Gambio Experten unter euch oder vielleicht sogar von einem Gambianer . Vorgehensweise: Ich überlade die Methode... PHP: $xtcPrice->get_properties_combi_price($combiId, 0, true, $this->percentage); ...um einen weiteren Parameter. In diesem Fall $this->percentage = 10. Die "message" kommt auch in der Methode an (siehe Bild_1). Daraufhin ersetze ich die Methode zu Testzwecken PHP: $xtcPrice->get_properties_combi_price($combiId, 0, true, $this->percentage); mit PHP: $coo_properties_control->get_properties_combis_price($p_combis_id, $this->percentage); und überlade diese um einen weiteren Parameter. Auch in diesem Fall $this->percentage = 10. Die Message kommt auch in dieser Methode an (siehe Bild_2) Wenn ich jedoch der Logik von Gambio folge und erst eine "message" nach PHP: $xtcPrice->get_properties_combi_price($combiId, 0, true, $this->percentage); sende und von da aus die "message" an PHP: $coo_properties_control->get_properties_combis_price($p_combis_id, $percentage); weiterleite, kommt nichts an (siehe Bild_3). Die Frage ist warum, was übersehe ich? Bitte um weitere Unterstützung seitens Gambio oder Experten unter euch, da sich laut Forum doch viele Mitglieder einen Fix wünschen.
Hmm... wir kommen der Sache ein wenig näher... Bitte einmal nachrechnen Nur eine Sache stört mich noch... Wird der rabattierte Prozentsatz mathematisch oder kaufmännisch errechnet in einem Shop???
Kann bitte einer bei sich im Testshop den Fix testen, da ich nicht alle Varianten die vorkommen können abbilden kann? Was macht der Fix? Es errechnet den rabattierten Gesamtpreis samt Attributen. (Eigenschaften kommen später ) Die zwei Klassen dürfen jedoch nicht bereits überladen sein! Natürlich erst an einem Testshop testen!!! Einen Ordner "user_classes/overloads/xtcPrice" mit der Datei "BugfixXtcPrice.php" erstellen und folgenden Code einfügen PHP: <?php/* -------------------------------------------------------------- Gambio GmbH http://www.gambio.de Copyright (c) 2016 Gambio GmbH Released under the GNU General Public License (Version 2) [http://www.gnu.org/licenses/gpl-2.0.html] --------------------------------------------------------------*//*** Class BugfixXtcPrice 2016-05-26* Created by MONEVO.*/class BugfixXtcPrice extends BugfixXtcPrice_parent{ protected $percentage = 0; public function xtcGetOptionPrice($p_products_id, $p_options_id, $p_options_values_id) { $cacheKey = $this->_generateCacheKey(__METHOD__.serialize(func_get_args())); if ($this->dataCache->key_exists($cacheKey)) { return $this->dataCache->get_data($cacheKey); } $t_option_data_array = array(); $t_sql = "SELECT pd.products_discount_allowed, pd.products_tax_class_id, p.options_values_price, p.price_prefix, p.options_values_weight, p.weight_prefix FROM ".TABLE_PRODUCTS_ATTRIBUTES." p, ".TABLE_PRODUCTS." pd WHERE p.products_id = '".(int)$p_products_id."' AND p.options_id = '".(int)$p_options_id."' AND pd.products_id = p.products_id AND p.options_values_id = '".(int)$p_options_values_id."'"; $t_result = xtc_db_query($t_sql); if (xtc_db_num_rows($t_result) > 0) { $t_result_array = xtc_db_fetch_array($t_result); $t_discount = 0; if ($this->cStatus['customers_status_discount_attributes'] == 1 && $this->cStatus['customers_status_discount'] != 0.00 && $this->xtcCheckSpecial($p_products_id) == false) { $t_discount = $this->cStatus['customers_status_discount']; if ($t_result_array['products_discount_allowed'] < $this->cStatus['customers_status_discount']) { $t_discount = $t_result_array['products_discount_allowed']; } } if ($t_result_array['products_tax_class_id'] != 0) { $t_price = $this->xtcFormat($t_result_array['options_values_price'], false, $t_result_array['products_tax_class_id']); } else { $t_price = $this->xtcFormat($t_result_array['options_values_price'], false, $t_result_array['products_tax_class_id'], true); } if ($t_result_array['weight_prefix'] != '+') { $t_result_array['options_values_weight'] *= -1; } if ($t_result_array['price_prefix'] == '+') { $t_price = $t_price - $t_price / 100 * $t_discount; } else { $t_price = ($t_price - $t_price / 100 * $t_discount) * -1; } $specialPrice = $this->xtcCheckSpecial($p_products_id); $normalPrice = $this->getPprice($p_products_id); if ($specialPrice < $normalPrice && $specialPrice > 0) { $this->setPercentage($specialPrice, $normalPrice); } $t_option_data_array['weight'] = $t_result_array['options_values_weight']; $t_option_data_array['price'] = $this->percentage != 0 ? $t_price - $t_price / 100 * $this->percentage : $t_price; } $this->dataCache->set_data($cacheKey, $t_option_data_array); return $this->dataCache->get_data($cacheKey); } /** * @return int */ public function getPercentage() { return $this->percentage; } /** * @param $specialPrice * @param $normalPrice * @return int */ public function setPercentage($specialPrice, $normalPrice) { $this->percentage = ceil(round((1 - ($specialPrice / $normalPrice)) * 100, 1)); }} Danach noch den Ordner "user_classes/overloads/CheckStatusController" mit der Datei "BugfixCheckStatusController.php" erstellen und folgenden Code einfügen. PHP: <?php/* -------------------------------------------------------------- Gambio GmbH http://www.gambio.de Copyright (c) 2016 Gambio GmbH Released under the GNU General Public License (Version 2) [http://www.gnu.org/licenses/gpl-2.0.html] --------------------------------------------------------------*//*** Class BugfixCheckStatusController 2016-05-26* Created by MONEVO.*/class BugfixCheckStatusController extends BugfixCheckStatusController_parent{ protected function _getDiscount() { require_once DIR_FS_INC.'xtc_get_tax_class_id.inc.php'; $combiPrice = 0; $discount = ''; $xtcPrice = new xtcPrice($_SESSION['currency'], $_SESSION['customers_status']['customers_status_id']); if (isset($_GET['properties_values_ids'])) { $propertiesControl = MainFactory::create_object('PropertiesControl'); $combiId = $propertiesControl->get_combis_id_by_value_ids_array(xtc_get_prid($_GET['products_id']), $_GET['properties_values_ids']); $combiPrice = $xtcPrice->get_properties_combi_price($combiId); } $specialPrice = $xtcPrice->xtcCheckSpecial($_GET['products_id']) + $combiPrice; $normalPrice = $xtcPrice->getPprice($_GET['products_id']) + $combiPrice; $isSpecial = false; if ($specialPrice < $normalPrice && $specialPrice > 0) { $xtcPrice->setPercentage($specialPrice, $normalPrice); $discount = -1 * $xtcPrice->getPercentage(); $isSpecial = true; } if (isset($_GET['id']) && is_array($_GET['id'])) { foreach ($_GET['id'] as $optionId => $valueId) { $optionPrice = $xtcPrice->xtcGetOptionPrice($_GET['products_id'], $optionId, $valueId); $specialPrice += $optionPrice['price']; $normalPrice += $optionPrice['price']; } } if ($isSpecial) { $discount = '<div class="ribbon-special"><span>'.$discount.'%</span></div>'; return $discount; } return $discount; }} Bei mir in der Testumgebung macht der Fix was er soll... Hab jedoch nicht nachgerechnet Artikelstandardpreis ist 1000€
bei mir erscheinen die ribbons nicht, liegt wohl daran dass ich Deinen Fix aus diesem Thread eingebaut habe: (Link nur für registrierte Nutzer sichtbar.)
habe den Fix mal entfernt. Bei mir passt es aber nicht. Beispiel Bausatz Jimenez: Grundpreis UVP 4.211,00, bei 8% Rabatt kommt Gambio auf 3.871,00 EUR. Wenn ich jetzt ein Attribut mit Aufpreis von 200 EUR hinzufüge, ist der UVP nicht 4.411,00 EUR sonder es werden 4.393,00 EUR angezeigt und der rabattierte Preis mit 4.053,00 EUR. Das zumindest könnte fast stimmen hier: (Link nur für registrierte Nutzer sichtbar.)
@marmoles bitte einmal dieses testen "user_classes/overloads/CheckStatusController/BugfixCheckStatusController.php" PHP: <?php/* -------------------------------------------------------------- Gambio GmbH http://www.gambio.de Copyright (c) 2016 Gambio GmbH Released under the GNU General Public License (Version 2) [http://www.gnu.org/licenses/gpl-2.0.html] --------------------------------------------------------------*//*** Class BugfixCheckStatusController 2016-05-26* Created by MONEVO.*/class BugfixCheckStatusController extends BugfixCheckStatusController_parent{ protected function _getDiscount() { require_once DIR_FS_INC.'xtc_get_tax_class_id.inc.php'; $combiPrice = 0; $discount = ''; $xtcPrice = new xtcPrice($_SESSION['currency'], $_SESSION['customers_status']['customers_status_id']); if (isset($_GET['properties_values_ids'])) { $propertiesControl = MainFactory::create_object('PropertiesControl'); $combiId = $propertiesControl->get_combis_id_by_value_ids_array(xtc_get_prid($_GET['products_id']), $_GET['properties_values_ids']); $combiPrice = $xtcPrice->get_properties_combi_price($combiId); } $specialPrice = $xtcPrice->xtcCheckSpecial($_GET['products_id']) + $combiPrice; $normalPrice = $xtcPrice->getPprice($_GET['products_id']) + $combiPrice; $isSpecial = false; if ($specialPrice < $normalPrice && $specialPrice > 0) { $xtcPrice->setPercentage($specialPrice, $normalPrice); $discount = -1 * $xtcPrice->getPercentage(); $isSpecial = true; } if (isset($_GET['id']) && is_array($_GET['id'])) { foreach ($_GET['id'] as $optionId => $valueId) { $optionPrice = $xtcPrice->xtcGetOptionPrice($_GET['products_id'], $optionId, $valueId); $specialPrice += $optionPrice['price']; $normalPrice += $optionPrice['price']; } } if ($isSpecial) { $discount = '<div class="ribbon-special"><span>'.$discount.'%</span></div>'; return $discount; } return $discount; }} "user_classes/overloads/GMAttributesCalculator/BugfixGMAttributesCalculator.php" PHP: <?php/* -------------------------------------------------------------- Gambio GmbH http://www.gambio.de Copyright (c) 2016 Gambio GmbH Released under the GNU General Public License (Version 2) [http://www.gnu.org/licenses/gpl-2.0.html] --------------------------------------------------------------*//*** Class BugfixAttributesCalculator 2016-05-26* Created by MONEVO.*/class BugfixGMAttributesCalculator extends BugfixGMAttributesCalculator_parent{ public function attributes_price($with_percentage = true) { global $xtPrice; $t_attributes_price = 0; $t_customers_status_discount_attributes_copy = $xtPrice->cStatus['customers_status_discount_attributes']; $xtPrice->cStatus['customers_status_discount_attributes'] = 0; // kein Rabatt berechnen, da Gesamtpreis später rabattiert wird for ($i = 0; $i < count($this->attributes_array); $i++) { $t_values_array = $xtPrice->xtcGetOptionPrice($this->products_id, $this->attributes_array[$i]['option'], $this->attributes_array[$i]['value'], $with_percentage); $t_attributes_price += $t_values_array['price']; } $xtPrice->cStatus['customers_status_discount_attributes'] = $t_customers_status_discount_attributes_copy; // alten Zustand wiederherstellen return $t_attributes_price; } public function calculate($p_quantity = 1, $p_format = false, $p_currency = false, $p_return_array = 0) { global $xtPrice; $t_price = 0; if ($xtPrice->cStatus['customers_status_show_price_tax'] != '0') { $t_tax_rate = $xtPrice->TAX[$this->tax_class_id]; } else { $t_tax_rate = 0; } $t_price = $xtPrice->getPprice($this->products_id); if ($this->combis_id > 0) { $t_combi_price = $xtPrice->get_properties_combi_price($this->combis_id, 0, false); $t_price += $t_combi_price; } // graduated sPrice $quantity = $p_quantity + xtc_get_qty($this->products_id); $graduated_sPrice = $xtPrice->xtcGetGraduatedPrice($this->products_id, $quantity, $this->combis_id); // check specialprice $t_new_price = $xtPrice->xtcCheckSpecial($this->products_id, $this->combis_id); if (empty($t_new_price) === false) { $t_price = $xtPrice->xtcFormatSpecial( $this->products_id, $xtPrice->xtcAddTax($t_new_price, $t_tax_rate) + $this->attributes_price(), $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(false), $p_format, $p_return_array); } // check graduated elseif ($xtPrice->cStatus['customers_status_graduated_prices'] == '1' && !empty($graduated_sPrice) && $graduated_sPrice != $t_price) { if ($graduated_sPrice < $t_price) { $t_price = $xtPrice->xtcFormatSpecialGraduated( $this->products_id, $xtPrice->xtcAddTax($graduated_sPrice, $t_tax_rate) + $this->attributes_price(), $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(), $p_format, $p_return_array, $this->products_id); } else { $t_price = $xtPrice->xtcFormat( $xtPrice->xtcAddTax($graduated_sPrice, $t_tax_rate) + $this->attributes_price(), $p_format, 0, $p_currency, $p_return_array, $this->products_id); } } // check Group Price elseif ($xtPrice->xtcGetGroupPrice($this->products_id, $p_quantity, $this->combis_id)) { $t_new_price = $xtPrice->xtcGetGroupPrice($this->products_id, $p_quantity, $this->combis_id); if ($t_new_price < $t_price) { $t_price = $xtPrice->xtcFormatSpecialGraduated( $this->products_id, $xtPrice->xtcAddTax($t_new_price, $t_tax_rate) + $this->attributes_price(), $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(), $p_format, $p_return_array, $this->products_id); } elseif ($xtPrice->xtcCheckDiscount($this->products_id)) { $t_discount = $xtPrice->xtcCheckDiscount($this->products_id); if ($xtPrice->cStatus['customers_status_discount_attributes'] == '1') { $t_price = $xtPrice->xtcFormatSpecialDiscount( $this->products_id, $t_discount, $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(), $p_format, $p_return_array); } else { $t_price = $xtPrice->xtcFormatSpecialDiscount( $this->products_id, $t_discount, $xtPrice->xtcAddTax($t_price, $t_tax_rate), $p_format, $p_return_array, $this->attributes_price()); } } else { $t_price = $xtPrice->xtcFormat( $xtPrice->xtcAddTax($t_new_price, $t_tax_rate) + $this->attributes_price(), $p_format, 0, $p_currency, $p_return_array, $this->products_id); } } // check Product Discount elseif ($xtPrice->xtcCheckDiscount($this->products_id)) { $t_discount = $xtPrice->xtcCheckDiscount($this->products_id); if ($this->combis_id != 0) { $t_price -= $t_combi_price; } $t_combi_price = $xtPrice->get_properties_combi_price($this->combis_id, $this->tax_class_id); if ($xtPrice->cStatus['customers_status_discount_attributes'] == '1' && $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price() != 0) { $t_price = $xtPrice->xtcFormatSpecialDiscount( $this->products_id, $t_discount, $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(), $p_format, $p_return_array, 0, $t_combi_price); } else { $t_price = $xtPrice->xtcFormatSpecialDiscount( $this->products_id, $t_discount, $xtPrice->xtcAddTax($t_price, $t_tax_rate), $p_format, $p_return_array, $this->attributes_price(), $t_combi_price); } } // normal price else { $t_price = $xtPrice->xtcFormat( $xtPrice->xtcAddTax($t_price, $t_tax_rate) + $this->attributes_price(), $p_format, 0, $p_currency, $p_return_array, $this->products_id); } return $t_price; }} "user_classes/overloads/xtcPrice/BugfixXtcPrice.php" PHP: <?php/* -------------------------------------------------------------- Gambio GmbH http://www.gambio.de Copyright (c) 2016 Gambio GmbH Released under the GNU General Public License (Version 2) [http://www.gnu.org/licenses/gpl-2.0.html] --------------------------------------------------------------*//*** Class BugfixXtcPrice 2016-05-26* Created by MONEVO.*/class BugfixXtcPrice extends BugfixXtcPrice_parent{ protected $percentage = 0; public function xtcGetOptionPrice($p_products_id, $p_options_id, $p_options_values_id, $calculate_percentage = true) { $specialPrice = $this->xtcCheckSpecial($p_products_id); $normalPrice = $this->getPprice($p_products_id); if ($specialPrice < $normalPrice && $specialPrice > 0) { $this->setPercentage($specialPrice, $normalPrice); } $cacheKey = $this->_generateCacheKey(__METHOD__.serialize(func_get_args())); if ($this->dataCache->key_exists($cacheKey)) { return $this->dataCache->get_data($cacheKey); } $t_option_data_array = array(); $t_sql = "SELECT pd.products_discount_allowed, pd.products_tax_class_id, p.options_values_price, p.price_prefix, p.options_values_weight, p.weight_prefix FROM ".TABLE_PRODUCTS_ATTRIBUTES." p, ".TABLE_PRODUCTS." pd WHERE p.products_id = '".(int)$p_products_id."' AND p.options_id = '".(int)$p_options_id."' AND pd.products_id = p.products_id AND p.options_values_id = '".(int)$p_options_values_id."'"; $t_result = xtc_db_query($t_sql); if (xtc_db_num_rows($t_result) > 0) { $t_result_array = xtc_db_fetch_array($t_result); $t_discount = 0; if ($this->cStatus['customers_status_discount_attributes'] == 1 && $this->cStatus['customers_status_discount'] != 0.00 && $this->xtcCheckSpecial($p_products_id) == false) { $t_discount = $this->cStatus['customers_status_discount']; if ($t_result_array['products_discount_allowed'] < $this->cStatus['customers_status_discount']) { $t_discount = $t_result_array['products_discount_allowed']; } } if ($calculate_percentage) { $t_discount = $this->percentage; } if ($t_result_array['products_tax_class_id'] != 0) { $t_price = $this->xtcFormat($t_result_array['options_values_price'], false, $t_result_array['products_tax_class_id']); } else { $t_price = $this->xtcFormat($t_result_array['options_values_price'], false, $t_result_array['products_tax_class_id'], true); } if ($t_result_array['weight_prefix'] != '+') { $t_result_array['options_values_weight'] *= -1; } if ($t_result_array['price_prefix'] == '+') { $t_price = $t_price - $t_price / 100 * $t_discount; } else { $t_price = ($t_price - $t_price / 100 * $t_discount) * -1; } $t_option_data_array['weight'] = $t_result_array['options_values_weight']; //$t_option_data_array['price'] = $this->percentage != 0 ? $t_price - $t_price / 100 * $this->percentage : $t_price; $t_option_data_array['price'] = $t_price; } $this->dataCache->set_data($cacheKey, $t_option_data_array); return $this->dataCache->get_data($cacheKey); } /** * @return int */ public function getPercentage() { return $this->percentage; } /** * @param $specialPrice * @param $normalPrice * @return int */ public function setPercentage($specialPrice, $normalPrice) { $this->percentage = ceil(round((1 - ($specialPrice / $normalPrice)) * 100, 1)); }} Auf meiner Testumgebung macht es nun was es soll... Hab jedoch nicht nachgerechnet Glaube das war es mit dem Fix
Einen Fix für Eigenschaften lasse ich besser sein, sonst haut mir Gambio noch auf die Finger Bei Attributen ist es ja nicht sooo schlimm, da bald raus aus dem Programm
scheint zu funktionieren , man könnte natürlich kleinlich sein und es besser finden wenn die Prozentangabe wenigstens 1 Stelle hinter dem Komma anzeigen würde.......
Deswegen ja "abgerundet" und nicht "aufgerundet". Lieber habe ich 7% Rabatt stehen und es sind rechnerisch 7,6% anstatt 8% stehen zu haben und der Kunde nöhlt, weil es keine 8% sondern nur 7,6% sind.
Nun ja, wenn du z.B. ein Artikel in Brutto für regulär 1000€ verkaufst und ein Rabatt von 100€ bzw. 10% auf diesen Artikel gewährst, dann geht das System hin und legt diese als Netto in der Datenbank ab und rechnet die MwSt. bei der Ausgabe wieder auf. Alter Preis 1000€ / 1,19 = 840,3361€ Netto in der Datenbank abgelegt (wenn im Backend auf vier Dezimalstellen eingestellt ist) Neuer Preis 900€ / 1,19 = 756,3025€ Netto in der Datenbank abgelegt Den Prozentsatz errechnet das System dann mit den zwei Werten aus der Datenbank Also: 756,3025 / 840,3361 = 0,9000 Danach wird umgestellt und umgestellt und umgestellt und umgestellt und.... bis endlich am Ende eine 10 ausgegeben wird. Du siehst, dass je nach Prozentsatz eine Stelle nach dem Komma wenig ausmacht, da Rundungsfehler immer vorhanden sind.