Jump to content

How to get how many customers in the shop


ZiedDams
 Share

Recommended Posts

Checked by email.
You enter a query query into the database in the ps_orders table to see if the email exists.

For advice, you must enter your entire hookActionCustomerAccountAdd function here.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you @knacky 🙂 for your comment , I actually solved this  by doing this after a user signup ( in the hook ActionCustomerAccountAdd)

 

            $q = "SELECT COUNT(*) 'count' FROM "._DB_PREFIX_."customer";

            $result = $this->db->executeS($q);

            $count = (int)$result[0]['count'];

            return $count < $n_users;

 

The $n_users is a variable holding the number 200 in the above example i have explained , My whole idea is  if the user singed up  is in the first 200 users i will give him a small gift

  • Like 1

Share this post


Link to post
Share on other sites

$db = Db::getInstance();

$idCustomer = $params['id_customer'];

$getTopCustomers = $db->executeS('SELECT id_customer FROM '._DB_PREFIX_.'customer ORDER BY id_customer LIMIT 200');

$foundIn200 = false;

foreach ($getTopCustomers as $customer) {

    if ($customer['id_customer'] == $idCustomer) {$foundIn200 = true; break;}

}

if ($foundIn200 == true){your send gift function}

Edited by knacky (see edit history)
  • Thanks 2

Share this post


Link to post
Share on other sites

$db = Db::getInstance();

$idCustomer = $params['id_customer'];

$customer = $db->getValue('SELECT id_customer FROM '._DB_PREFIX_.'customer WHERE id_customer = '.$id_customer );

$getNumRow = $db->numRows();

if ($getNumRow < 200)

{your send gift function}

  • Thanks 1

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More