Jump to content

call a function when an order is completed


Oplus99

Recommended Posts

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

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/

  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

  • 3 weeks later...

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

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

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

  • 1 year later...

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...