Modul Staffelpreise

Was für Wünsche habt ihr an den WEB-Shop.
Forumsregeln
Welche Module/Features sollen integriert werden, wo könnte man etwas besser machen?
Antworten
basteldehs
Beiträge: 77
Registriert: So 20. Okt 2013, 06:29
Shop Version: 1.0.17
Wohnort: Chemnitz
Kontaktdaten:

Modul Staffelpreise

Beitrag von basteldehs »

Hallo Yogi,

so hier mal wie besprochen, das Modul Staffelpreis von xtc:load, ob sich das lohnt einzubauen oder nicht, wegen den Zukünftigen Shop Updates:

das ist die Installationsanweisung

Code: Alles auswählen

1. BACKUP MACHEN!!!

2. Datenbank

für weitere Kundengruppen bitte entsprechend ergänzen

ALTER TABLE `products` CHANGE `products_discount_allowed` `products_discount_allowed` DECIMAL( 4, 2 ) NOT NULL DEFAULT '0.00';
ALTER TABLE `personal_offers_by_customers_status_0` ADD `special_offer` DECIMAL( 15, 4 ) NULL;
ALTER TABLE `personal_offers_by_customers_status_1` ADD `special_offer` DECIMAL( 15, 4 ) NULL;
ALTER TABLE `personal_offers_by_customers_status_2` ADD `special_offer` DECIMAL( 15, 4 ) NULL;
ALTER TABLE `personal_offers_by_customers_status_3` ADD `special_offer` DECIMAL( 15, 4 ) NULL;
2. Dateien kopieren

admin/includes/modules/group_prices.php
admin/includes/javascript/group_prices.js

3. Anpassungen an Dateien

admin/includes/classes/categories.php

Funktion insert_product

ca. Zeile 462

        if (PRICE_IS_BRUTTO == 'true' && $products_data['products_price']) {
            $products_data['products_price'] = round(($products_data['products_price'] / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100), PRICE_PRECISION);
        }
davor einfügen
        $products_data['products_price'] = $this->correctPrice($products_data['products_price']);
ca. Zeile 644

$personal_price = xtc_db_prepare_input($products_data['products_price_'.$group_data[$col]['STATUS_ID']]);
danach einfügen
$special_price = xtc_db_prepare_input($products_data['special_price_'.$group_data[$col]['STATUS_ID']]);
ca. Zeile 647

} else {
danach einfügen
$personal_price = $this->correctPrice($personal_price);
ca. Zeile 654

                if ($action == 'insert') {
davor einfügen
davor einfügen
                if ($special_price == '' || $special_price == '0.0000') {
                    $special_price = '0.00';
                } elseif (substr($special_price, -1) == '%')  {
                    $special_price = ($personal_price - (($this->correctPrice($special_price) / 100) * $personal_price));
                } else {
                    $special_price = $this->correctPrice($special_price);
                    if (PRICE_IS_BRUTTO == 'true') {
                        $special_price = ($special_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100);
                    }
                    $special_price = xtc_round($special_price, PRICE_PRECISION);
                }
ca. Zeile 665

                    xtc_db_query("UPDATE personal_offers_by_customers_status_".$group_data[$col]['STATUS_ID']."
												                 SET personal_offer = '".$personal_price."'
												               WHERE products_id = '".$products_id."'
												                 AND quantity    = '1'");
ändern in
                    xtc_db_query("UPDATE personal_offers_by_customers_status_".$group_data[$col]['STATUS_ID']."
                                     SET personal_offer = '".$personal_price."',
                                         special_offer  = '".$special_price."'
                                   WHERE products_id = '".$products_id."'
                                     AND quantity    = '1'");
ca. Zeile 686

			if ($group_data[$col]['STATUS_ID'] != '') {
danach einfügen
                $id = xtc_db_prepare_input($products_data['products_id_staffel_'.$group_data[$col]['STATUS_ID']]);
ca. Zeile 688

                $staffelpreis = xtc_db_prepare_input($products_data['products_price_staffel_'.$group_data[$col]['STATUS_ID']]);
danach einfügen
                $specialpreis = xtc_db_prepare_input($products_data['products_special_staffel_'.$group_data[$col]['STATUS_ID']]);
                foreach ($staffelpreis as $k=>$preis) {
                    $menge = trim(stripslashes($quantity[$k]));
                    $preis = $this->correctPrice($preis);
                    if ( ( !xtc_not_null($preis) || !xtc_not_null($menge) ) && isset($id[$k]) && $id[$k] != '') {
                        xtc_db_query('DELETE FROM ' . TABLE_PERSONAL_OFFERS_BY . $group_data[$col]['STATUS_ID'] . " WHERE products_id=$products_id AND price_id=" . $id[$k]);
                        continue;
                    }

                    if (xtc_not_null($preis)) {
                        $special_price = $this->correctPrice($specialpreis[$k]);
ca. Zeile 689

				if (PRICE_IS_BRUTTO == 'true') {
					$staffelpreis = ($staffelpreis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100);
				}
				$staffelpreis = xtc_round($staffelpreis, PRICE_PRECISION);

				if ($staffelpreis != '' && $quantity != '') {
					// ok, lets check entered data to get rid of user faults
					if ($quantity <= 1)
						$quantity = 2;
					$check_query = xtc_db_query("SELECT quantity
														                               FROM personal_offers_by_customers_status_".$group_data[$col]['STATUS_ID']."
														                              WHERE products_id = '".$products_id."'
														                                AND quantity    = '".$quantity."'");
					// dont insert if same qty!
					if (xtc_db_num_rows($check_query) < 1) {
						xtc_db_query("INSERT INTO personal_offers_by_customers_status_".$group_data[$col]['STATUS_ID']."
																	                 SET price_id       = '',
																	                     products_id    = '".$products_id."',
																	                     quantity       = '".$quantity."',
																	                     personal_offer = '".$staffelpreis."'");
					}
				}
			}
		}
ändern in
                        if (PRICE_IS_BRUTTO == 'true') {
                            $preis = ($preis / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100);
                        }
                        if (substr($special_price, -1) == '%')  {
                            $special_price = ($preis - (($special_price / 100) * $preis));
                        } elseif (PRICE_IS_BRUTTO == 'true') {
                            $special_price = ($special_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100);
                        }
                        // ok, lets check entered data to get rid of user faults
                        if ($menge <= 1) $menge = 2;
                        if (isset($id[$k]) && $id[$k] != '') {
                            xtc_db_query('UPDATE ' . TABLE_PERSONAL_OFFERS_BY . $group_data[$col]['STATUS_ID']."
                                          SET quantity       = '".$menge."',
                                              personal_offer = '".$preis."',
                                              special_offer  = '".$special_price."'
                                          WHERE price_id = " . $id[$k] . "
                                          AND products_id = " . $products_id);
                        } else {
                            xtc_db_query('INSERT INTO ' . TABLE_PERSONAL_OFFERS_BY . $group_data[$col]['STATUS_ID']."
                                          SET price_id       = '',
                                              products_id    = '".$products_id."',
                                              quantity       = '".$menge."',
                                              personal_offer = '".$preis."',
                                              special_offer  = '".$special_price."'");
                        }
                    }
                }
            }
        }

        $special_price = xtc_db_prepare_input($products_data['specials_price']);
        $special_status = xtc_db_prepare_input($products_data['specials_status']);
        $special_quantity = xtc_db_prepare_input($products_data['specials_quantity']);
        $expires_date = xtc_db_prepare_input($products_data['expires_date']);

        if (substr($special_price, -1) == '%')  {
            $special_price = ($products_data['products_price'] - (($special_price / 100) * $products_data['products_price']));
        } elseif (PRICE_IS_BRUTTO == 'true') {
            $special_price = ($special_price / (xtc_get_tax_rate($products_data['products_tax_class_id']) + 100) * 100);
        }


        $sql_data_array = array('products_id' => $products_id, 'specials_quantity' => $special_quantity, 'specials_new_products_price' => $special_price, 'expires_date' => $expires_date, 'status' => $special_status);
        $special_query = xtc_db_query("SELECT specials_id FROM " . TABLE_SPECIALS . " WHERE products_id=" . $products_id . " ORDER BY specials_date_added DESC LIMIT 1");
        if (xtc_db_num_rows($special_query)) {
            $special_result = xtc_db_fetch_array($special_query);
            $insert_sql_data = array ('specials_last_modified' => 'now()');
            $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
            xtc_db_perform(TABLE_SPECIALS, $sql_data_array, 'update', 'specials_id = \''.$special_result['specials_id'].'\'');
        } else {
            if ($special_price > 0.0 || $special_status == 1) {
                $insert_sql_data = array ('specials_date_added' => 'now()');
                $sql_data_array = xtc_array_merge($sql_data_array, $insert_sql_data);
                xtc_db_perform(TABLE_SPECIALS, $sql_data_array);
            }
        }
Am Ende der Datei

    // ----------------------------------------------------------------------------------------------------- //

} // class categories ENDS
?>
ändern in
    function correctPrice($price)
    {
        $price = str_replace(',', '.', $price);
        $values = explode('.', $price);
        $count = count($values) - 1;
        if ($count <= 1) {
            return $price;
        }
        for ($i=0; $i<($count); $i++) {
            $string .= $value[$i];
        }
        $string .= '.' . $values[$count];
        return $string;

    }
    // ----------------------------------------------------------------------------------------------------- //

} // class categories ENDS
?>
admin/includes/functions/general.php

ca. Zeile 1491

function format_price($price_string, $price_special, $currency, $allow_tax, $tax_rate) {
davor einfügen
function get_special_price($group_id, $product_id) {
    $special_price_query = xtc_db_query("SELECT special_offer FROM ".TABLE_PERSONAL_OFFERS_BY.$group_id." WHERE products_id = '".$product_id."' and quantity=1");
    if (xtc_db_num_rows($special_price_query)) {
        $special_price_data = xtc_db_fetch_array($special_price_query);
        return $special_price_data['special_offer'];
    }
    return 0;
}
admin/categories.php

ca. Zeile 281

        <script type="text/javascript" src="includes/javascript/categories.js"></script>
danach einfügen
        <script type="text/javascript" src="includes/javascript/group_prices.js"></script>
includes/classes/product.php

ca. Zeile 339

	/**
	 *
	 * valid flag
	 *
	 */

	function isProduct() {
		return $this->isProduct;
	}
davor einfügen
    function getSpecialGraduated() {
        global $xtPrice;

        $special_query = xtc_db_query("SELECT status FROM " . TABLE_SPECIALS . " WHERE products_id=" . $this->pID . " AND status=1");
        if (xtc_db_num_rows($special_query) == 0) {
            return false;
        }

        $staffel_query = xtDBquery("SELECT quantity,
                                           special_offer
                                    FROM ".TABLE_PERSONAL_OFFERS_BY.(int) $_SESSION['customers_status']['customers_status_id']."
                                    WHERE products_id = '".$this->pID."'
                                    AND special_offer > 0.0
                                    ORDER BY quantity ASC");

        $staffel = array ();
        while ($staffel_values = xtc_db_fetch_array($staffel_query, true)) {
            $staffel[] = array ('stk' => $staffel_values['quantity'], 'price' => $staffel_values['special_offer']);
        }
        $discount = $xtPrice->xtcCheckDiscount($this->pID);
        $staffel_data = array ();
        $n = sizeof($staffel);
        if ($n == 0) return false;
        for ($i = 0; $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 = $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 * $discount, true, $this->data['products_tax_class_id']));
        }
        return $staffel_data;
    }
includes/classes/xtcPrice.php

ca. Zeile 95

        if ($sPrice = $this->xtcCheckSpecial($pID)) {
            return $this->xtcFormatSpecial($pID, $this->xtcAddTax($sPrice['normal'], $products_tax), $pPrice, $format, $vpeStatus);
        }
ersetzen durch
        if ($sPrice = $this->xtcCheckSpecial($pID, $qty)) {
            return $this->xtcFormatSpecial($pID, $this->xtcAddTax($sPrice['special'], $products_tax), $this->xtcAddTax($sPrice['normal'], $products_tax), $format, $vpeStatus, $this->xtcAddTax($sPrice['lowest'], $products_tax), $this->xtcAddTax($sPrice['highest'], $products_tax));
        }
Funktion xtcCheckSpecial ersetzen durch

    function xtcCheckSpecial($pID, $qty) {
        if ($this->cStatus['customers_status_graduated_prices'] == '1') {
            $status_query = xtc_db_query("SELECT specials_id FROM " . TABLE_SPECIALS . " WHERE products_id=" . (int)$pID . " AND status=1");
            if (xtc_db_num_rows($status_query) > 0) {
                $graduated_price_query = "SELECT quantity as qty,
                                                 personal_offer,
                                                 special_offer
                                          FROM ".TABLE_PERSONAL_OFFERS_BY.$this->actualGroup."
                                          WHERE products_id=" . (int)$pID . "
                                          AND special_offer > 0.0
                                          ORDER BY quantity DESC";
                $graduated_price_query = xtDBquery($graduated_price_query);
                if (xtc_db_num_rows($graduated_price_query)) {
                    $i = 0;
                    $lowestPrice = 0.00;
                    $highestPrice = 0.00;
                    $sPrice = 0.00;
                    while ($graduated_price_data = xtc_db_fetch_array($graduated_price_query, true)) {
                        if ($i++ == 0 && $graduated_price_data['qty'] > 1) {
                            $lowestPrice = $graduated_price_data['special_offer'];
                        }
                        if ($sPrice == 0.00 && $graduated_price_data['qty'] <= $qty) {
                            $sPrice = $graduated_price_data['special_offer'];
                            $pPrice = $graduated_price_data['personal_offer'];
                        }
                        $highestPrice = $graduated_price_data['special_offer'];
                    }
                    if ($sPrice != 0.00 )
                    return array('special' => $sPrice, 'lowest' => $lowestPrice, 'highest' => $highestPrice, 'normal' => $pPrice);
                }
            } else {
                return false;
            }
        }
        $product_query = "select specials_new_products_price from ".TABLE_SPECIALS." where products_id = " . (int)$pID . " and status=1";
        $product_query = xtDBquery($product_query);
        $product = xtc_db_fetch_array($product_query, true);
        if ($product['specials_new_products_price'] == 0) return false;
        return array('normal' => $product['specials_new_products_price'], 'lowest' => 0, 'highest' => 0);
    }
Funktion xtcFormatSpecial ersetzen durch

    function xtcFormatSpecial($pID, $sPrice, $pPrice, $format, $vpeStatus = 0, $lowest = 0, $highest = 0) {
        if ($discount = $this->xtcCheckDiscount($pID)) {
            $sPrice -= $sPrice / 100 * $discount;
            $lowest -= $lowest / 100 * $discount;
            $highest -= $highest / 100 * $discount;
        }
        if ($format) {
            if ($lowest == 0) {
                $price = '<span class="productOldPrice">'.INSTEAD.$this->xtcFormat($pPrice, $format).'</span><br />'.ONLY.$this->checkAttributes($pID).$this->xtcFormat($sPrice, $format);
            } else {
                $sPrice = $lowest;
                $price = '<span class="productOldPrice">'.INSTEAD.$this->xtcFormat($pPrice, $format).'</span><br />'.NOW.FROM.$this->checkAttributes($pID).$this->xtcFormat($sPrice, $format);
            }
            if ($vpeStatus == 0) {
                return $price;
            } else {
                return array ('formated' => $price, 'plain' => $sPrice);
            }
        } else {
            return round($sPrice, $this->currencies[$this->actualCurr]['decimal_places']);
        }
    }
includes/modules/graduated_prices.php

ca. Zeile 23

$staffel_data = $product->getGraduated();
danach einfügen
$special_data = $product->getSpecialGraduated();
ca. Zeile 28

    $module_smarty->assign('module_content', $staffel_data);
danach einfügen
    $module_smarty->assign('special_content', $special_data);
lang/german/admin/categories.php

Am Ende (vor dem ?>) einfügen

define('TXT_QUANTITY', 'Menge');
define('TXT_SPECIALOFFERS', 'Sonderpreise');
define('TXT_SPECIAL_OFFER', 'Sonderangebot');
define('TXT_NEW_STAFFELPREIS', 'Neuer Staffelpreis');
define('TEXT_SPECIALS_ENABLED', 'Sonderangebot aktiv:');
define('TEXT_SPECIALS_SPECIAL_QUANTITY', 'Anzahl:');
define('TEXT_SPECIALS_EXPIRES_DATE', 'G&uuml;ltig bis:<br /><small>(yyyy-mm-dd)</small>');
define('TEXT_SPECIALS_PRICE_TIP', '<b>Bemerkung:</b><ul><li>Sie k&ouml;nnen in den Feldern Sonderpreise auch prozentuale Werte angeben, z.B.: <b>20%</b></li><li>Lassen Sie das Feld <b>\'G&uuml;ltig bis\'</b> leer, wenn der Angebotspreis zeitlich unbegrenzt gelten soll.</li></ul>');
lang/german/german.php

Am Ende anfügen (vor dem ?>)

define('NOW', 'jetzt ');
lang/german/lang_german.conf

ca. Zeile 436, Sektion [graduated_price]

[graduated_price]
heading_text = 'Staffelpreise'
pieces = 'je'
unit = 'Stk.'
danach einfügen
special_text = 'Angebotspreise'
templates/TEMPLATE/module/graduated_price.html

am Ende anfügen
{if $special_content}
<br />
<br />

<table width="100%" border="0" style="background: #CFC;">
  <tr>
    <td colspan="2" class="infoBoxHeading"><div align="center">{#special_text#}</div></td>
  </tr>
  {foreach name=aussen item=module_data from=$special_content}
  <tr>
    <td class="main" nowrap="nowrap" valign="top">{$module_data.QUANTITY} {#unit#}</td>
    <td class="main" nowrap="nowrap">{#pieces#} {$module_data.PRICE}{if $module_data.VPE}<br />{$module_data.VPE}{/if}</td>
  </tr>
  {/foreach}
</table>
{/if}

einfach nur ja oder finger davon

Danke und LG
Mein Online Shop http://www.bastel-dehs.de
Antworten