kdk 1 Posted March 24, 2009 Posted March 24, 2009 Here is the extend "Bill me later module" based on the Cash-on-Delivery-ModulFunctions (You have to edit the billmelater.php in Line 31):Exclude Carriers by IDMaximum amount for the basketMinimum orders before Billing is possibleSpecial thanks to the great d0m1n1k The discussion:Hi, I search for a method to include a query in the "Bill me later"-Module. So only Customer with more than 5 orders can pay later by bill.I include a query for a basketlimit and for carrier: function hookPayment($params) { global $smarty; if ((intval($params['cart']->id_carrier))==29) return; if ((intval($params['cart']->getOrderTotal(true, 4)))>250) return; But how can i include a query with "nb_orders" ?Thanks in advance.(I'm using Version 1.0) billmelater.zip Share this post Link to post Share on other sites
kdk 1 Posted March 25, 2009 Posted March 25, 2009 Is really nobody out there who has an idea about this?I think using this: '.$this->l('Valid orders placed:').' '.$customerStats['nb_orders'].' from the AdminOrders.php is a little help. Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Really, really nobody out there who has an idea? Is this such a complicated question? Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 $customer = new Customer($order->id_customer); $customerStats = $customer->getStats(); then you sould be able to use $customerStats['nb_orders']you might have to change the $order->id_customer to $cart->id_customer to get a result.greetings Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Thanks a lot. But this overcharges me a little bit.Where should i put this code in? in the billmelater.php? I dont know what to do. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 i'd put it into your function hookpayment ($params){ ...tell me if it works Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 This is the code of the billmelater.php <?php $smarty->debugging = true; class BillMeLater extends PaymentModule { function __construct() { $this->name = 'billmelater'; $this->tab = 'Payment'; $this->version = 0.1; parent::__construct(); /* The parent construct is required for translations */ $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('Rechnungskauf'); $this->description = $this->l('Kauf auf Rechnung'); } function install() { parent::install(); $this->registerHook('payment'); $this->registerHook('paymentReturn'); } function hookPayment($params) { global $smarty; if ((intval($params['cart']->id_carrier))==29) return; if ((intval($params['cart']->getOrderTotal(true, 4)))>250) return; $customer = new Customer($cart->id_customer); $customerStats = $customer->getStats(); if ((intval($params['cart']->nb_orders))<2) return; /* Photo is copyrighted by Leticia Wilson - Fotolia.com, licenced to PrestaShop company */ $smarty->assign(array( 'this_path' => $this->_path, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/' )); return $this->display(__FILE__, 'payment.tpl'); } function hookPaymentReturn($params) { return $this->display(__FILE__, 'confirmation.tpl'); } } ?> No errors, but no effect. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 try $customer = new Customer($cart->id_customer); $customerStats = $customer->getStats(); if ((intval($customerStats->nb_orders))<2) return;the return things are a bit confusing for me. whats the use of them? Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 The same: No errors, no effect.Customer has 3 orders (maybe i'm wrong with the logic?) if ((intval($params['cart']->id_carrier))==29) return; Customers outside Germany but inside the EU didnt see this Pay-Module. if ((intval($params['cart']->getOrderTotal(true, 4)))>250) return; Exludes all Carts with more then 250 Euro.I have the code from the dutch-Forum. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 global $smarty; $customer = new Customer($cart->id_customer); $customerStats = $customer->getStats(); if (intval($params['cart']->id_carrier)==29 && (intval($params['cart']->getOrderTotal(true, 4)))>250 && intval($customerStats->nb_orders)>5) { commands to be executed if all 3 are true } Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 global $smarty; $customer = new Customer($cart->id_customer); $customerStats = $customer->getStats(); if ((intval($params['cart']->id_carrier))!=29 && (intval($params['cart']->getOrderTotal(true, 4)))<250 && intval($params['cart']->nb_orders)>5) I have changed ==29 to !=29 because carrier with id=29 has to be excluded. This works, but intval($params['cart']->nb_orders)>5 seems to have no effect Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 hi thats because i had a bug inside check the last part again and you will notice that i've changed the $params['cart'] to $customerStats Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 if ((intval($params['cart']->id_carrier))!=29 && (intval($params['cart']->getOrderTotal(true, 4)))<250 && intval($customerStats->nb_orders)>2) has also no effect the payment-module will not shown if ((intval($params['cart']->id_carrier))!=29 && (intval($params['cart']->getOrderTotal(true, 4)))<250) this code worksI seh gerade das Du deutsch sprichst. Was mach ich nur falsch? Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 ich war schon länger am überlegn ob wir die sprache nicht wechseln sollten es könnte sein dass presta dich aus dem modul nicht auf die customer klasse lässt, wär zwar komisch aber möglich. global $smarty; $customers_id = $params['cart']->id_customer; $hack_nb_orders = Db::getInstance()->getRow(' SELECT COUNT(`id_order`) AS nb_orders, SUM(`total_paid`) AS total_orders FROM `'._DB_PREFIX_.'orders` o WHERE o.`id_customer` = '$customers_id' AND o.valid = 1'); if (intval($params['cart']->id_carrier)==29 && (intval($params['cart']->getOrderTotal(true, 4)))>250 && intval($customerStats->nb_orders)>5) { oder global $smarty; $customer = new Customer($params['cart']->id_customer); $customerStats = $customer->getStats(); if (intval($params['cart']->id_carrier)==29 && (intval($params['cart']->getOrderTotal(true, 4)))>250 && intval($customerStats->nb_orders)>2) { (versuch zuerst das letzte, ist sauberer ) Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Sind da syntax-fehler drin? Ich hab nur eine weiße Seite.... Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Auch auf die Gefahr, dass ich langsam lästig werde:1. Lösung führt zu weißer Seite2. Lösung hat keinen Effekt Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 <?php $smarty->debugging = true; class BillMeLater extends PaymentModule { function __construct() { $this->name = 'billmelater'; $this->tab = 'Payment'; $this->version = 0.1; parent::__construct(); /* The parent construct is required for translations */ $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('Rechnungskauf'); $this->description = $this->l('Kauf auf Rechnung'); } function install() { parent::install(); $this->registerHook('payment'); $this->registerHook('paymentReturn'); } function hookPayment($params) { global $smarty; $customers_id = $params['cart']->id_customer; $hack_nb_orders = Db::getInstance()->getRow(' SELECT COUNT(`id_order`) AS nb_orders, SUM(`total_paid`) AS total_orders FROM `'._DB_PREFIX_.'orders` o WHERE o.`id_customer` = '$customers_id' AND o.valid = 1'); if (intval($params['cart']->id_carrier)==29 && (intval($params['cart']->getOrderTotal(true, 4)))>250 && intval($customerStats->nb_orders)>5) { /* Photo is copyrighted by Leticia Wilson - Fotolia.com, licenced to PrestaShop company */ $smarty->assign(array( 'this_path' => $this->_path, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/' )); return $this->display(__FILE__, 'payment.tpl'); [spam-filter] function hookPaymentReturn($params) { return $this->display(__FILE__, 'confirmation.tpl'); } } ?> Die komplette billmelater.php, die zur weissen Seite führt. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 function hookPayment($params) { global $smarty; $customer = new Customer($params['cart']->id_customer); $customerStats = $customer->getStats(); if(intval($params['cart']->id_carrier)==29 && intval($params['cart']->getOrderTotal(true, 4))>250 && intval($customerStats[nb_orders])>6) { $smarty->assign(array( 'this_path' => $this->_path, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/' )); return $this->display(__FILE__, 'payment.tpl'); } } funktioniert bei mir, hab mir das modul nun extra nachgebaut.es sind definitiv in dem bereich keine syntaxfehler drinnen, ich kann dir auch die ganze datei schicken.die bedingungen reagieren auch richtig auf veränderungen, wenn ich weniger als 250 im korb habe wirds nicht angezeigt, für kunden mit weniger als 6 bestellungen wirds auch nicht angezeigt. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 in deiner lösung musst du in der zeile WHERE o.`id_customer` = '$customers_id' vor und nach $customers_id noch einen punkt machen: WHERE o.`id_customer` = '.$customers_id.' (würde dir aber sowieso empfehlen die lösung aus #17 zu verwenden) Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Inzwischen bin ich glaub ich zu blöd den Code zu kopieren. Ich bekomme immer nur eine weisse Seite. Könntest Du wirklich mal die ganze Datei dranhängen? Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Kommando zurück. Es scheint zu funktionieren, ich bau es jetzt mal in den echten Shop ein. Share this post Link to post Share on other sites
d0m1n1k 0 Posted March 26, 2009 Posted March 26, 2009 jetzt bin ich aber gespannt :long: Share this post Link to post Share on other sites
kdk 1 Posted March 26, 2009 Posted March 26, 2009 Oh Mann, danke, danke, danke. Es funktioniert tadellos.Öhm, ich weiss ja nicht wie Du zu den angebotenen Produkten stehst. Aber wenn ich mich irgendwie erkenntlich zeigen kann ;-)Ist nicht mein Shop, aber das wäre ne Möglichkeit. Share this post Link to post Share on other sites
lachaca 1 Posted May 3, 2009 Posted May 3, 2009 Hallo Presta Gemeindebin seit gestern nach langem Suchen eines geeigneten Shops auf Presta gestossen.Hat mich (trotz vieler negativer Ausagen) echt überzeugt, und ich glaube hier stecktnoch einiges an Potenzial. Vieles ist auch schon klar und einfach geregelt aber.....wie kriege ich das Modul billmelater in meine Shop rein. Mein Kunde will nur gegenRechnung verschicken... und das wärs ja genau...2 verschiedene Vorgehensweise bringen keinen Erfolg???Back-Office - neues Modul installieren - URL eingeben:(hier habe ich ein Verzeichnis auf dem Servergemacht und das ZIP file hochgeladen - diesen Pfad gebe ich an, dann paswort des admin => Erfolg = this is not a valid module URL (must end with .tar) dann habe ich als 2. Versuch ein neues directory in den modules erstellt und alles reinkopiert....==> leider findet er das Modul dann auch nicht...kann ihr mir oder sonst jemand aus dem Forum viellleicht einen Tipp geben. vielen DankNachtrag: habe das file in tar konvertiert... und siehe da.. es funktioniert ;-)alos weiter gehts mit testen. Hoffe ich kann in ein paar Woche auch mit Rat und Tat zur Verfügung stehen . Share this post Link to post Share on other sites
lachaca 1 Posted May 4, 2009 Posted May 4, 2009 Leider zu früh gefreut ;-(Installation hat funktioniert aber dann....wenn ich cashondelivery ausschalte/deinstalliere, wird mir die Zahlungsmöglichkeit nicht mehr angezeigt.Wenn ich COD eingeschaltet habe dann kommt die Zahlmöglichkeit aber wie mir scheint mit dem Symbol (gif)aus dem cashondelivery Ordner ?? auch der Link (http://xxxxx/modules/cashondelivery/validation.php) scheint auf diesen Ordner zu zeigen ??ich habe die produktanzahl auf 1 und den Wert des Einkaufs auf 20 gesetzt. sollte also angezeigt werden.bin ich zu blöd das zu kapieren. Auch nach 2 Stunden suchen habe ich keinen Lösungsansatz!habt ihr einen Tipp?Vielen Dank und GrussMarcel Share this post Link to post Share on other sites
jolvil 78 Posted May 22, 2009 Posted May 22, 2009 Could you write in english in this post please ? Share this post Link to post Share on other sites
kdk 1 Posted May 22, 2009 Posted May 22, 2009 The interesting part is in english. The german part are only questions to some details. Share this post Link to post Share on other sites
frosticek 3 Posted March 29, 2011 Posted March 29, 2011 Is there any version of Bill Me Later module on 1.4 version of PS ? Share this post Link to post Share on other sites
ladyred 3 Posted October 20, 2011 Posted October 20, 2011 WOW excellent just what i wanted!!! Thank you Share this post Link to post Share on other sites
gjalvarez 0 Posted June 12, 2012 Posted June 12, 2012 WOW excellent just what i wanted!!! Thank you where you able to use it? can you share last version? I need it too! Share this post Link to post Share on other sites
gjalvarez 0 Posted July 14, 2012 Posted July 14, 2012 I have been trying to use this module using prestashop 1.4.8.2 but there is no way I can get throw it, I would appreciatte if anyone can give me a hand... Thanks in advanced Share this post Link to post Share on other sites
Recommended Posts