Oplus99 Posted August 1, 2011 Share Posted August 1, 2011 Hi, I want to know where to put my function and where I can call it back. basically, when I user pays for an item and it is approved. I want to call a function with parameters. the parameters will be: order number internal account number (id of the customer) customer name address city state zip code country code phone number email shipment method carrier code shipper account number item# quantity ordered so I need access of all of these info. In brief, When someone clicks on I confirm my order and the ordered was successfully paid and approved. I want to call a function and pass the parameters above to that function so it can do its work. 1. where do I put my function? 2. where do I call my function? 3. How do I access those info? Much appreciate it. Link to comment Share on other sites More sharing options...
olea Posted August 1, 2011 Share Posted August 1, 2011 Hi, I want to know where to put my function and where I can call it back. basically, when I user pays for an item and it is approved. I want to call a function with parameters. the parameters will be: order number internal account number (id of the customer) customer name address city state zip code country code phone number email shipment method carrier code shipper account number item# quantity ordered so I need access of all of these info. In brief, When someone clicks on I confirm my order and the ordered was successfully paid and approved. I want to call a function and pass the parameters above to that function so it can do its work. 1. where do I put my function? 2. where do I call my function? 3. How do I access those info? Much appreciate it. The best way is to create a module that hooks on the hook NewOrder. You may find info on : http://doc.prestashop.com/ 1 Link to comment Share on other sites More sharing options...
Oplus99 Posted August 1, 2011 Author Share Posted August 1, 2011 But I dont want it to be controlled on the back office... is there any other way to do that? like just call a function when an ordered has been placed? Thanks, Link to comment Share on other sites More sharing options...
olea Posted August 1, 2011 Share Posted August 1, 2011 I didn't mean you will control it from the back office Prestashop calls hooks in many places during execution. In particular, the NewOrder hook is called when a new order is confirmed. So, you can write a module that will be called by this hook and exécute the code you want. 1 Link to comment Share on other sites More sharing options...
Oplus99 Posted August 1, 2011 Author Share Posted August 1, 2011 I didn't mean you will control it from the back office Prestashop calls hooks in many places during execution. In particular, the NewOrder hook is called when a new order is confirmed. So, you can write a module that will be called by this hook and exécute the code you want. Okay I understand, please could you provide me a link where I can read on how to create hooks? because the url you gave me doesnt have a page where it help us create one. Thanks, Link to comment Share on other sites More sharing options...
acateon Posted August 1, 2011 Share Posted August 1, 2011 Ever heard of Google? http://lmgtfy.com/?q=prestashop+how+to+create+hooks&l=1 Link to comment Share on other sites More sharing options...
olea Posted August 2, 2011 Share Posted August 2, 2011 You can take the MailAlerts or Loyalties modules as examples. You will see how to create the module, how to hook to hooks (they use the hookNewOrder) 1 Link to comment Share on other sites More sharing options...
Oplus99 Posted August 19, 2011 Author Share Posted August 19, 2011 Thanks for your help olea . I have created a module that is hooked with newOrder. the file is been created successfully. However now how can I get customer information in a php file? and I also need access to the order info. Please anyone help. Thanks, Link to comment Share on other sites More sharing options...
olea Posted August 19, 2011 Share Posted August 19, 2011 Thanks for your help olea . I have created a module that is hooked with newOrder. the file is been created successfully. However now how can I get customer information in a php file? and I also need access to the order info. Please anyone help. Thanks, In the hook parameter (the $param), you should retrieve this info. Link to comment Share on other sites More sharing options...
Oplus99 Posted August 20, 2011 Author Share Posted August 20, 2011 How can I turn id to string ? example: $params["cart"]->id_address_delivery is an id.. I want the text of that address and not the id.. Please help me with that thanks, Link to comment Share on other sites More sharing options...
Oplus99 Posted August 20, 2011 Author Share Posted August 20, 2011 I got a turn around to this. I am using the database to get strings $customer_full_address = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT a.address1, a.address2, a.postcode, a.city, a.phone, st.name AS state, cl.name AS country FROM ps_address a, ps_state st, ps_country_lang cl WHERE a.id_address = '.$cart->id_address_delivery.' AND a.id_state = st.id_state AND a.id_country = cl.id_country AND cl.id_lang = 1'); then I can have $customer_city = $customer_full_address[0]["city"]; Thanks, Link to comment Share on other sites More sharing options...
Matteo ulivi Posted November 22, 2012 Share Posted November 22, 2012 Sorry, does anyone know how to have a var_dump of $ params Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted November 22, 2012 Share Posted November 22, 2012 (edited) Hi, Oplus99, in your example (post #11) using getRow instead of executeS allows the use $customer_full_address["city"] Matteo ulivi, just use var_dump($params) or print_r($params) Regards Edited November 22, 2012 by Alexander Simonchik (see edit history) Link to comment 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