ZiedDams Posted February 11, 2022 Posted February 11, 2022 im create a module with registering this hook ActionCustomerAccountAdd all i want is check if customer is in the first 200 users registered to the shop any help ? Share this post Link to post Share on other sites More sharing options...
knacky Posted February 12, 2022 Posted February 12, 2022 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. 1 Share this post Link to post Share on other sites More sharing options...
ZiedDams Posted February 15, 2022 Posted February 15, 2022 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 1 Share this post Link to post Share on other sites More sharing options...
knacky Posted February 16, 2022 Posted February 16, 2022 (edited) $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 February 16, 2022 by knacky (see edit history) 2 Share this post Link to post Share on other sites More sharing options...
knacky Posted February 16, 2022 Posted February 16, 2022 $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} 1 Share this post Link to post Share on other sites More sharing options...
knacky Posted February 16, 2022 Posted February 16, 2022 You have two examples of how to do it. Choose the one that suits you better. 1 1 Share this post Link to post Share on other sites More sharing options...
ZiedDams Posted February 16, 2022 Posted February 16, 2022 4 hours ago, knacky said: You have two examples of how to do it. Choose the one that suits you better. thank your for your time, I will use your 1st example 1 Share this post Link to post Share on other sites More sharing options...
Mediacom87 Posted February 17, 2022 Posted February 17, 2022 (edited) Hi, $nb_customers = count(Customer::getCustomers(true)); Edited February 17, 2022 by Mediacom87 (see edit history) 1 Share this post Link to post Share on other sites More sharing options...
ZiedDams Posted February 17, 2022 Posted February 17, 2022 1 hour ago, Mediacom87 said: Hi, $nb_customers = count(Customer::getCustomers(true)); that's so cool and easy, Thank you Share this post Link to post Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now