[1.4.11] Versandmodul

MyOOS hat einen Fehler, oder tut nicht das, was Ihr erwartet? Derartige "Unanehmlichkeiten" bitte hier.
Antworten
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

Hallo,

kann mir einer helfen: das modul für pauschale Versandkosten ist ja schon vorhanden nur bräuchte ich es so das bei einer Bestellung von Produkten verschiedener Lieferanten das nicht kombiniert wird sondern die pauschale halt mehrfach berechnet wird. Das heist wenn ich Produkt1 von HerstellerA und Produkt2 von HerstellerB bestelle die versandpauschale von 10€ zweimal berechnet wird, dann also 20€ beträgt. Bei 1 oder mehr Produkten von einem Hersteller bleiben die Versandkosten bei 10€. Und bei Produkten von 2 oder mehr verschiedenen Herstellern werden die Versandkosten jeweils für jeden Hersteller einmal berechnet.
Denke man müsste das Modul der pauschlen versandkosten so erweitern das es die Hersteller der Produkte prüft.
Vermute wenn man sich mit dem ganzen Aufbau des Shops auskennt ist dies sehr einfach.

Vielen Dank schonmal.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Hallo,

Pauschale Versandkosten

sind in der Klasse
~/shop/includes/modules/shipping/flat.php


Für eine Erweitung würde ich mir den Inhalt von dem Objekt $oOrder ausgeben lassen.
Vermutlich muss man die Datenbankabfrage ändern

~/shop/includes/classes/class_order.php

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> $orders_productstable = $oostable['orders_products];
$sql = "SELECT orders_products_id, products_id, products_name, products_model,
products_ean, products_serial_number, products_price, products_tax,
products_quantity, final_price
FROM $orders_productstable
WHERE orders_id = '" . intval($order_id) . "'";
$orders_products_result = $dbconn->Execute($sql);
while ($orders_products = $orders_products_result->fields) {
$this->products[$index] = array('qty' => $orders_products['products_quantity],
'id' => $orders_products['products_id],
'name' => $orders_products['products_name],
'model' => $orders_products['products_model],
'ean' => $orders_products['products_ean],
'serial_number' => $orders_products['products_serial_number],
'tax' => $orders_products['products_tax],
'price' => $orders_products['products_price],
'final_price' => $orders_products['final_price]);<!--c2-->[/align]<!--ec2-->

Hier fehlt die Abfrage nach dem Hersteller. In der Produkt-Datenbanktablle steht der Hersteller
in in dem feld manufacturers_id

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> $orders_productstable = $oostable['orders_products];
$sql = "SELECT orders_products_id, products_id, products_name, products_model,
products_ean, products_serial_number, products_price, products_tax,
manufacturers_id, products_quantity, final_price
FROM $orders_productstable
WHERE orders_id = '" . intval($order_id) . "'";
$orders_products_result = $dbconn->Execute($sql);
while ($orders_products = $orders_products_result->fields) {
$this->products[$index] = array('qty' => $orders_products['products_quantity],
'id' => $orders_products['products_id],
'name' => $orders_products['products_name],
'model' => $orders_products['products_model],
'ean' => $orders_products['products_ean],
'serial_number' => $orders_products['products_serial_number],
'manufacturers_id' => $orders_products['manufacturers_id],
'tax' => $orders_products['products_tax],
'price' => $orders_products['products_price],
'final_price' => $orders_products['final_price]);<!--c2-->[/align]<!--ec2-->

in function cart() {

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> $products = $_SESSION['cart]->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$this->products[$index] = array('qty' => $products[$i]['quantity],
'name' => $products[$i]['name],
'model' => $products[$i]['model],
'ean' => $products[$i]['ean],
'tax' => oos_get_tax_rate($products[$i]['tax_class_id], $billing_address['entry_country_id], $$billing_address['entry_zone_id]),
'tax_description' => oos_get_tax_description($products[$i]['tax_class_id], $billing_address['entry_country_id], $billing_address['entry_zone_id]),
'price' => $products[$i]['price],
'final_price' => $products[$i]['price] + $_SESSION['cart]->attributes_price($products[$i]['id]),
'weight' => $products[$i]['weight],
'towlid' => $products[$i]['towlid],
'id' => $products[$i]['id]);<!--c2-->[/align]<!--ec2-->

fehlt der Hersteller auch
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Ps.

am einfachsten erweitert man den Warenkorb

~/shop/includes/classes/class_shopping_cart

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function calculate() {
$this->cont_manufacturers = 0;<!--c2-->[/align]<!--ec2-->

und hier dann sich

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> while (list($products_id, ) = each($this->contents)) {
$nQuantity = $this->contents[$products_id]['qty];

// products price
$productstable = $oostable['products];
$product_sql = "SELECT products_id, products_model, products_price, products_discount_allowed,
products_tax_class_id, products_weight
FROM $productstable
WHERE products_id='" . oos_get_product_id($products_id) . "'";
$product_result = $dbconn->Execute($product_sql);
if ($product = $product_result->fields) {
$no_count = 1;
if (ereg('^GIFT', $product['products_model])) {
$no_count = 0;
}

$prid = $product['products_id];
$products_tax = oos_get_tax_rate($product['products_tax_class_id]);
if ($_SESSION['member]->group['qty_discounts] == 1) {
$products_price = $this->products_price_actual($prid, $product['products_price], $nQuantity);
} else {
$products_price = $product['products_price];
}
$max_product_discount = min($product['products_discount_allowed], $_SESSION['member]->group['discount]);
$products_price = $products_price*(100-$max_product_discount)/100;

$products_weight = $product['products_weight];
$bSpezialPrice = false;

$specialstable = $oostable['specials];
$sql = "SELECT specials_new_products_price
FROM $specialstable
WHERE products_id = '" . intval($prid) . "'
AND status = '1'";
$specials_result = $dbconn->Execute($sql);
if ($specials_result->RecordCount()) {
$specials = $specials_result->fields;
$products_price = $specials['specials_new_products_price];
$bSpezialPrice = true;
}

$this->total_virtual += oos_add_tax($products_price, $products_tax) * $nQuantity * $no_count;
$this->weight_virtual += ($nQuantity * $products_weight) * $no_count;
$this->total += oos_add_tax($products_price, $products_tax) * $nQuantity;
$this->weight += ($nQuantity * $products_weight);
}<!--c2-->[/align]<!--ec2-->

hier sich etwas einfallen lassen, wie man die Hersteller zählen hann.
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

Danke für die Hilfe.

Jetz müsste ich noch irgendwie die Hersteller IDs vergleichen und wenn eine neue dazu kommt den Counter um 1 inkrementieren.
Also müsste ich auch irgendwie festhalten ob ich die ID schoneinmal gezählt habe.
Und zum Schluss noch die Versandpauschale mit dem Wert des Counters multiplizieren.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Danke für die Hilfe.

Jetz müsste ich noch irgendwie die Hersteller IDs vergleichen und wenn eine neue dazu kommt den Counter um 1 inkrementieren.
Also müsste ich auch irgendwie festhalten ob ich die ID schoneinmal gezählt habe.
Und zum Schluss noch die Versandpauschale mit dem Wert des Counters multiplizieren.
Bertrachte doch einfach mal


class_shopping_cart
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function count_contents() { // get total number of items in cart
$total_items = 0;
if (is_array($this->contents)) {
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$total_items += $this->get_quantity($products_id);
}
}

return $total_items;
}<!--c2-->[/align]<!--ec2-->

und mit

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1-->$_SESSION['cart]->count_contents()<!--c2-->[/align]<!--ec2-->

Steht dir das Ergebnis zur Verfügung.

Wenn du wissen möchtest, wieviel Hersteller in deinem Warenkorb sind, solltest du dir eine
vergleichbare Methode einfachen lassen.


Die Produkt-Anzahl holen wir uns so:
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function get_quantity($products_id) {
if (isset($this->contents[$products_id])) {
$nQuantity = $this->contents[$products_id]['qty];
return $nQuantity;
} else {
return 0;
}
}<!--c2-->[/align]<!--ec2-->


Und wir Prüfen so, ob ein Produkt im Warenkorb ist

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function in_cart($products_id) {
if (isset($this->contents[$products_id])) {
return true;
} else {
return false;
}
}<!--c2-->[/align]<!--ec2-->



Du kannst evtl. mit
in-array
http://de2.php.net/manual/de/function.in-array.php

oder bei einer anderen Gestaltung auch mit
array-key-exists
http://de2.php.net/manual/de/function.a ... exists.php

Prüfen, ob die Hersteller_id vorhanden ist.


Wenn der Shop im Debug-Modus ist, zeigt er dir an, wie er was in der Session hat.
Der Warenkorb ist in der Session.

~/shop/includes/oos_nice_exit.php
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> echo '<pre>';
print_r($_SESSION);
echo '</pre>';<!--c2-->[/align]<!--ec2-->
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

Danke,

verstehe jetz wie es theoretisch geht nur weiß ich leider nicht wirklich wie ich es im Shop anwenden muss.
Kenne mich mit dem Programmieren leider nur sehr wenig aus.
Werder mal gucken ob ich irgendwas zusammengebastelt kriege.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Hallo,
verstehe jetz wie es theoretisch geht nur weiß ich leider nicht wirklich wie ich es im Shop anwenden muss.
ich habe zwei unterschiedliche Lösungswege aufgezeigt. Einmal habe ich mit
der notwendigen Datenbank-Abfrage Änderung begonnen und auf der
anderen Seite habe ich mit Notwenigen Erweiterung der Klasse begonnen.

Für die ersten Schritte würde ich mir in

~/shop/includes/oos_nice_exit.php

den Warenkorb ausgeben

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> echo '<pre>';
print_r($_SESSION['cart]);
echo '</pre>';<!--c2-->[/align]<!--ec2-->


eine mögliche Ausgabe

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1-->shoppingCart Object
(
[contents] => Array
(
[1] => Array
(
[qty] => 1
[towlid] =>
)

)

[total] => 15.000009
[weight] => 0.2
[cartID] => 64935
[content_type] =>
[total_virtual] => 15.000009
[weight_virtual] => 0.2
)<!--c2-->[/align]<!--ec2-->

Die PHP Klasse ist

~/shop/includes/classes/class_shopping_cart.php

Diese

[contents]
[total]
[weight]
[cartID]
[content_type]
[total_virtual]
[weight_virtual]

kennen noch keinen Counter für die Hersteller. Ergo eben einbauen


<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> class shoppingCart {
var $contents;
var $total;
var $weight;
var $cartID;
var $content_type;
var $count_manufacturers;<!--c2-->[/align]<!--ec2-->

Die Seite neu laden und schon kennt der Warenkorb einen Counter für Manufacturer :)

leider noch ohne Funktion ;)

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1-->shoppingCart Object
(
[contents] => Array
(
[1] => Array
(
[qty] => 1
[towlid] =>
)

)

[total] => 15.000009
[weight] => 0.2
[cartID] => 64935
[content_type] =>
[count_manufacturers] =>
[total_virtual] => 15.000009
[weight_virtual] => 0.2
)<!--c2-->[/align]<!--ec2-->


Ergo sucht man nun die Methode, die die "Summen" bildet und fügt für den Anfang einen
Wert (null = zahl) ein

Zeile 403
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function calculate() {

$this->total_virtual = 0; // Gift Voucher System
$this->weight_virtual = 0;
$this->total = 0;
$this->weight = 0;
$this->count_manufacturers= 0;<!--c2-->[/align]<!--ec2-->

Man ruft den Shop auf, und hat jetzt NULL Hersteller!


Diese Erweiterung hätte selbstverständlich nur dann SINN, wenn man die Anzahl der Hersteller
im Warenkorb benötigt.

Der Ausgang war aber im Kassenbereich.

Die Klasse class_order.php holt sich mit

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> $products = $_SESSION['cart]->get_products();<!--c2-->[/align]<!--ec2-->

die Produkte aus dem Warenkorb.

ergo muss function get_products() { in Shop class_shopping_cart erweitert werden
(Hersteller aus der Datenbank Abfragen und in den Array schreiben.

Da die o.g. erweiterung verstanden wurde, fügen wir nun unter

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> print_r($_SESSION['cart]);<!--c2-->[/align]<!--ec2-->

ein
print_r($order);

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> print_r($_SESSION['cart]);
print_r($order);<!--c2-->[/align]<!--ec2-->

und erhält im Kassenbereich

<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1-->order Object
(
[info] => Array
(
[order_status] => 1
[currency] => EUR
[currency_value] => 1.00000000
[payment_method] =>
[cc_type] =>
[cc_owner] =>
[cc_number] =>
[cc_expires] =>
[cc_cvv] =>
[shipping_method] =>
[shipping_cost] =>
[comments] =>
[shipping_class] =>
[payment_class] =>
[subtotal] => 14.0187
[tax] => 0
[tax_groups] => Array
(
[0] => 0
)

[total] => 14.0187
)

[totals] => Array
(
)

[products] => Array
(
[0] => Array
(
[qty] => 1
[name] => dfasdfdasf
[model] =>
[ean] =>
[tax] => 0
[tax_description] => Unbekannter Steuersatz
[price] => 14.0187
[final_price] => 14.0187
[weight] => 0.20
[towlid] =>
[id] => 1
)

)

[customer] => Array
(
[firstname] => Ralf
[lastname] => Zschemisch
[company] =>
[street_address] => Thüringenenstr. 20
[suburb] => haspe
[city] => Hagen
[postcode] => 58135
[state] => NRW
[zone_id] => 0
[country] => Array
(
[id] => 81
[title] => Germany
[iso_code_2] => DE
[iso_code_3] => DEU
)

[format_id] => 5
[telephone] => 02331 44 511
[email_address] => info@r23.de
)

[delivery] => Array
(
[firstname] => Ralf
[lastname] => Zschemisch
[company] =>
[street_address] => Thüringenenstr. 20
[suburb] => haspe
[city] => Hagen
[postcode] => 58135
[state] => NRW
[zone_id] => 0
[country] => Array
(
[id] => 81
[title] => Germany
[iso_code_2] => DE
[iso_code_3] => DEU
)

[country_id] => 81
[format_id] => 5
)

[content_type] => physical
[billing] => Array
(
[firstname] =>
[lastname] =>
[company] =>
[street_address] =>
[suburb] =>
[city] =>
[postcode] =>
[state] =>
[country] => Array
(
[id] =>
[title] =>
[iso_code_2] =>
[iso_code_3] =>
[moneybookers] =>
)

[country_id] =>
[format_id] =>
)

)<!--c2-->[/align]<!--ec2-->




Wenn jetzt noch Probleme sind - kann ich nur noch bei *konkreten* Fragen hefen.


cu

ralf
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

Hallo,

mein Problem ist jetz das ich es nich hinkriege die hersteller ids zu vergleichen.

Wenn ich schreibe:
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1-->$this->count_manufacturers ++;<!--c2-->[/align]<!--ec2-->
in der function calculate() dann zählt der jedes Produkt.
Müsste die ids ja irgendwie mit in_array vergleichen nur kommt bei mir nix dabei rum.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Hallo,

kannst du mal zeigen, was du bis jetzt geändert hast?

cu

ralf
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

- eine Abfrage in ~/shop/includes/classes/class_order.php um die hersteller id zu kriegen

- in ~/shop/includes/classes/class_shopping_cart den counter erstellt
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> class shoppingCart {
var $contents;
var $total;
var $weight;
var $cartID;
var $content_type;
var $count_manufacturers;<!--c2-->[/align]<!--ec2-->
<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> function calculate() {
$this->cont_manufacturers = 0;<!--c2-->[/align]<!--ec2-->
und in function get_products() die Abfrage erstellt für die hersteller id


Und jetz versuche ich die Methode zu basteln in der function calculate() die die Hersteller zählen sollte aber bisscher ohne ergebniss.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Hallo,

ich weiss nicht, wo du genau bist.

kannst du mir deine geänderten Dateien zum Download zur Verfügung stellen?

dann baue ich dies mal in meine 1.6.14 ein---

zurzeit denke ich, dass du bei meinem posting vom 03.02.2009 bist (also bei einem Gedanken von vor Jahren)
hier sich etwas einfallen lassen, wie man die Hersteller zählen hann.

Möchtest du den counter im Warenkorb haben?
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

zurzeit denke ich, dass du bei meinem posting vom 03.02.2009 bist (also bei einem Gedanken von vor Jahren)
hier sich etwas einfallen lassen, wie man die Hersteller zählen hann.
Genau hier stehe ich ich komm nich weiter.
Wenn man die Methode zum zählen im Warenkorb hat macht es ja auch Sinn den Counter dort zu haben.
r23
Beiträge: 2696
Registriert: 18.09.2008, 05:56
Wohnort: Hagen
Kontaktdaten:

Beitrag von r23 »

Genau hier stehe ich ich komme nicht weiter.
Hilft dies weiter?


<!--c1--><div class='codetop'>QUELLTEXT[/align]<div class='codemain'><!--ec1--> $this->count_manufacturers = 0;

if (!is_array($this->contents)) return 0;

$db =& oosDBGetConn();
$oosDBTable = oosDBGetTables();

$aManufacturer = array();

reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$nQuantity = $this->contents[$products_id]['qty];

// products price
$product_sql = "SELECT products_id, products_model, products_price, products_discount_allowed,
products_tax_class_id, manufacturers_id, products_weight
FROM " . $oosDBTable['products] . "
WHERE products_id='" . oos_get_product_id($products_id) . "'";
$product_result = $db->Execute($product_sql);
if ($product = $product_result->fields) {


$nManufacturers_id = $product['manufacturers_id];

if (!in_array($nManufacturers_id, $aManufacturer)) {
$this->count_manufacturers ++;
$aManufacturer[] = $product['manufacturers_id];
}

echo '<pre>';
print_r($aManufacturer);
echo '</pre>';
echo $this->count_manufacturers;<!--c2-->[/align]<!--ec2-->
YinYang
Beiträge: 31
Registriert: 19.09.2008, 10:38
Wohnort: Lage
Kontaktdaten:

Beitrag von YinYang »

Jap das hilft weiter :).
Danke schön.

Kannst du mir vllt noch sagen wie ich den Counter jetz in einer anderen Funktion aufrufe (zb in der flat.php)?



*edit: Habs durch schon selber rausgefunden ($_SESSION['cart]->count_manufacturers). Scheint jetz so zu laufen wie ich es will.
Also vielen Dank nochmal.
Antworten