Jump to content

[SOLVED]Using getByEmail Function


burakco

Recommended Posts

hi,

 

i have fb2.php file in root dictonary and i want to check an e-mail address is used for registration, before by customer.

 

i found customerExists Function in classes/Customer.php file. how can i use this function in my php file?

 

 

i used this codes, but its not working :

 

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
$mail = $user->email;
$result = Customer::getByEmail($mail);
echo $result;

 

code result : blank page

Edited by burakco (see edit history)
Link to comment
Share on other sites

Hi,

 

Your request is really confusing, anyway the code here under will tell you the mail for an identified customer. If he is just guest you will not have his mail of course. In prestashop one mail equal one and only one customer.

 

require(dirname(__FILE__).'/config/config.inc.php');
$cookieLifetime = (time() + (((int)Configuration::get('PS_COOKIE_LIFETIME_FO') > 0 ? (int)Configuration::get('PS_COOKIE_LIFETIME_FO') : 1)* 3600));
       $cookie = new Cookie('ps', '', $cookieLifetime);
$id_customer = $cookie->__get('id_customer');
if ($id_customer){
$customer = new Customer($id_customer);

echo $customer->email;
}

 

You do not need to include 'init.php' it is 'made' by the config.inc.php and $user->mail is a lazy way to ask for correct method <_<

Link to comment
Share on other sites

thanks for your reply math_php ;)

 

i solve my problem with customerExists function in classes/custumer.php

 

public static function customerExists($email, $return_id = false, $ignoreGuest = true)
{
  if (!Validate::isEmail($email))
   die (Tools::displayError());
 $result = Db::getInstance()->getRow('
 SELECT `id_customer`
 FROM `'._DB_PREFIX_.'customer`
 WHERE `email` = \''.pSQL($email).'\''
 .($ignoreGuest ? 'AND `is_guest` = 0' : ''));
 if ($return_id)
  return (int)($result['id_customer']);
 else
  return isset($result['id_customer']);
}

 

 

usage :

 

$user->email = "[email protected]";
$result = Customer::customerExists($user->email);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...