PrestaShop Forums: Bill me later module only for regular customers and maximum basket (download it here) - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


Bill me later module only for regular customers and maximum basket (download it here)


Bill me later module only for regular customers and maximum basket (download it here)

#1 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 24 March 2009 - 07:36 PM

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



Quote


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)

Attached File(s)



#2 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 25 March 2009 - 01:53 PM

Is really nobody out there who has an idea about this?

I think using this:

Quote


'.$this->l('Valid orders placed:').' '.$customerStats['nb_orders'].'



from the AdminOrders.php is a little help.

#3 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 10:56 AM

Really, really nobody out there who has an idea? Is this such a complicated question?

#4 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 11:25 AM

 
$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

#5 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 11:36 AM

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.

#6 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 11:39 AM

i'd put it into your function hookpayment ($params){ ...

tell me if it works

#7 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 11:59 AM

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.

#8 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 12:02 PM

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?

#9 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 12:14 PM

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.

#10 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 12:25 PM


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
}


#11 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 12:40 PM


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

#12 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 01:02 PM

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

#13 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 01:28 PM


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?

#14 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 02:06 PM

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 ;) )

#15 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 02:58 PM

Sind da syntax-fehler drin? Ich hab nur eine weiße Seite....

#16 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 03:05 PM

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

#17 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 03:08 PM


<?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');
}}

function hookPaymentReturn($params)
{
return $this->display(__FILE__, 'confirmation.tpl');
}
}

?>


Die komplette billmelater.php, die zur weissen Seite führt.

#18 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 03:41 PM


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.

#19 d0m1n1k

    PrestaShop Apprentice

  • 19 Mar 2008
  • Members
  • PipPip
  • 284 posts
  • Location:Austria

Posted 26 March 2009 - 03:44 PM

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)

#20 kdk

    PrestaShop Apprentice

  • 15 Dec 2008
  • Members
  • PipPip
  • 231 posts

Posted 26 March 2009 - 03:50 PM

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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users