Bill me later module only for regular customers and maximum basket (download it here)
|
|
| Publié : 24 Mars 2009 09:36 PM |
[ Ignorer ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
Here is the extend “Bill me later module” based on the Cash-on-Delivery-Modul
Functions (You have to edit the billmelater.php in Line 31):
Exclude Carriers by ID
Maximum amount for the basket
Minimum orders before Billing is possible
Special 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)
Fichiers joints
|
|
|
|
|
|
| Publié : 25 Mars 2009 03:53 PM |
[ Ignorer ]
[ # 1 ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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.
|
|
|
|
|
|
| Publié : 26 Mars 2009 12:56 PM |
[ Ignorer ]
[ # 2 ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
Really, really nobody out there who has an idea? Is this such a complicated question?
|
|
|
|
|
|
| Publié : 26 Mars 2009 01:25 PM |
[ Ignorer ]
[ # 3 ]
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
$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
|
|
|
|
|
|
| Publié : 26 Mars 2009 01:36 PM |
[ Ignorer ]
[ # 4 ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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.
|
|
|
|
|
|
| Publié : 26 Mars 2009 01:39 PM |
[ Ignorer ]
[ # 5 ]
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
i’d put it into your function hookpayment ($params){ …
tell me if it works
|
|
|
|
|
|
| Publié : 26 Mars 2009 01:59 PM |
[ Ignorer ]
[ # 6 ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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.
|
|
|
|
|
|
| Publié : 26 Mars 2009 02:02 PM |
[ Ignorer ]
[ # 7 ]
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
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?
|
|
|
|
|
|
| Publié : 26 Mars 2009 02:14 PM |
[ Ignorer ]
[ # 8 ]
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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.
|
|
|
|
|
|
| Publié : 26 Mars 2009 02:25 PM |
[ Ignorer ]
[ # 9 ]
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
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 }
|
|
|
|
|
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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
|
|
|
|
|
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
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
|
|
|
|
|
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
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 works
I seh gerade das Du deutsch sprichst. Was mach ich nur falsch?
|
|
|
|
|
|
|
|
Senior Member
Messages :
- au total : 324
- 7 derniers jours : 0
Inscrit: 2008-03-19 |
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  )
|
|
|
|
|
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
Sind da syntax-fehler drin? Ich hab nur eine weiße Seite….
|
|
|
|
|
|
|
|
Club Member
Messages :
- au total : 223
- 7 derniers jours : 0
Inscrit: 2008-12-15 |
Auch auf die Gefahr, dass ich langsam lästig werde:
1. Lösung führt zu weißer Seite
2. Lösung hat keinen Effekt
|
|
|
|