[Skip to main content](#vessel-content)

#   add data to a table after order is confirmed

##

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14389](#14389) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  *[add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14389 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")* was created by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")*

I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

15 years 6 months ago [\#14395](#14395) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14395 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

You will need to create a plugin and implement the function onAfterOrderUpdate(&amp;$order,&amp;$send_email) of our API:
[ www.hikashop.com/en/support/documentatio...r-documentation.html](http://www.hikashop.com/en/support/documentation/62-hikashop-developer-documentation.html)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14413](#14413) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14413 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Hi nicolas,

I attempted to create a plugin for that so when order is updated, a coupon is created. This is my first time and it doesn't work, would you be able to tell me what I did wrong? thank you!

I placed it in joomla/plugins/hikashop/
and already registered it in the jos_plugin.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

15 years 6 months ago [\#14416](#14416) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14416 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Is it published ?
Do you see it in the joomla plugin manager ?
Could you post an archive of the files ?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14420](#14420) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14420 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

sorry i thought i attached the file. here you go.

yes it is published, i can see it in the plugin manager as well.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

15 years 6 months ago [\#14428](#14428) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14428 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

1. There is no xml file for your plugin in that archive. Without a properly defined xml file, the plugin won't work.
2. You wrote $order_&gt;order_full_price instead $order-&gt;order_full_price
3. The discount_id is generated automatically when saving a new coupon you should not specify it.
4. The discount_code should be unique for each coupon. So you need to make it dynamic, otherwise, if you already have a coupon with the same name it won't work.
5. You said that you wanted your code to run when the order was confirmed. As you wrote it, it will be triggered each time an order is modified. You should check the order_status attribute of the order.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14446](#14446) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14446 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Hi nicolas,

the reason y I only use static value such as 'testcode' for discount_code is because I wanted to see it working first before I put in any other things to complicate it. Also 'testcode' has never been created in discount before.
However, I've made the following changes, and the plugin still wouldn't create a discount entry for me. also attached php+xml files.

1. I've now included the xml file
2. I also fixed the $order_&gt;order_full_price to $order-&gt;order_full_price
3. I've removed the discount_id line.
4. I use order_id + today's date&amp;time as discount_code, so it's always unique
5. I've added the condition to check the order_status == 'confirmed'

I also tried with static values, still doesn't work. The plugin is called each time i change the order status (because if i have a syntax error in create_discount.php the order status will not change), but it never creates the discount entry.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14447](#14447) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14447 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

sorry uploaded the wrong file.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

15 years 6 months ago [\#14450](#14450) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14450 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Hi,

In your xml, and in the files name, you call your plugin create_coupon, so the name of the class should be plgHikashopCreate_coupon
That's probably why your plugin is not triggered. Joomla loads the file (so that's why you get the errors) but since the class name is not good, it's not able to register itself to the event and thus it is not triggered.

Instead of hikashop::getTime(getdate()) you can just do time()

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14455](#14455) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14455 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Ahhh!!! you are right! it adds the entry now!
But there's one problem, it's not assigning the order_full_price to the discount amount. is there something wrong with the following line:

$discount-&gt;discount_flat_amount = $order-&gt;order_full_price;

in my order table, the order_full_price field is 60.00, so i expect the discount amount to be 60.00 as well. is it wrong?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

15 years 6 months ago [\#14457](#14457) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14457 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

That's normal. You need to first load the order data.
When the function onAfterOrderUpdate is triggered, you don't know what is in $order. You can expect that there is order_id but that's all. Somewhere is the code you could just do like that:
$order = null;
$order-&gt;order_id = 5;
$order-&gt;order_status = "confirmed";
$orderClass = hikashop::get('class.order');
$orderClass-&gt;save($order);

So in your code, you will only get the id and the status.

So you need to load the order data before using that data:
if(empty($order-&gt;order_full_price)){
$orderClass = hikashop::get('class.order');
$dbOrder = $orderClass-&gt;get($order-&gt;order_id);
$order-&gt;order_full_price = $dbOrder-&gt;order_full_price;
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")**
- [![zerocul's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/2030-zerocul "View zerocul's Profile") Topic Author
- [ Offline](/forum/user/2030-zerocul)

Less More

- Posts: 20
- Thank you received: 0
-
-

15 years 6 months ago [\#14458](#14458) by [zerocul](/forum/user/2030-zerocul "View zerocul's Profile")  Replied by *[zerocul](/forum/user/2030-zerocul "View zerocul's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#14458 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

brilliant! Thank you Nicolas! the best support on earth!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")**
- [![ursule15's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4747-ursule15 "View ursule15's Profile")
- [ Offline](/forum/user/4747-ursule15)

Less More

- Posts: 10
- Thank you received: 0
-
-

14 years 10 months ago [\#31515](#31515) by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")  Replied by *[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31515 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Bonjour,

I need to perform same task : execute code after order is confirm.
I created a plugin :
defined('_JEXEC') or die('Restricted access');
?&gt;
&lt;?php
class plgHikashopBuy_AUP extends JPlugin
{
function onAfterOrderUpdate(&amp;$order,&amp;$send_email){
if(!empty($order-&gt;order_id)){
if($order-&gt;order_status == 'confirmed'){
//insert code here

Payment is not implemented in my website, so I have to test it manually.
This is working properly when a user creates an order. Order is with status created, if I switch status to confirm, plugin is triggered.

I have added bank transfer payment (easy to test with this one I guess).
And I have modified this payment processor (in the properties of the plugin) to have status Confirmed (instead of Created).
So when a user buys something with this payment processor, the order is generated with status Confirmed.

But here the plugin is not triggered.

Could you please explain why ?

Many thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

14 years 10 months ago [\#31545](#31545) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31545 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Bonjour,

That's because you implemented the function onAfterOrderUpdate which is only called when the order is updated. When the order is created, it's the function onAfterOrderCreate which is called and since you didn't implement it nothing happens.

For example, you can look at the hikashop history plugin where both functions are implemented since the plugin needs to be triggered in both cases.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")**
- [![ursule15's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4747-ursule15 "View ursule15's Profile")
- [ Offline](/forum/user/4747-ursule15)

Less More

- Posts: 10
- Thank you received: 0
-
-

14 years 10 months ago -  14 years 10 months ago [\#31549](#31549) by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")  Replied by *[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31549 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Do you think I am so stupid to have forgotten function onAfterOrderCreate ?
hum.... I AM so stupid !!

So I added :
function onAfterOrderCreate(&amp;$order,&amp;$send_email){
return $this-&gt;onAfterOrderUpdate($order,$send_email);
}

which is what you mean (correct ?).

But still no way to trigger the code when bank transfer (and Confirmed is the default status).

btw, I've noticed when I create an order like said before, the history of the order shows me 2 entry : one with status Created, and a second one with status Confirmed.
So I guess the function onAfterOrderUpdate should be enough (anyway, I've implemented your suggestion, which makes sense to me).
Maybe what is wrong here is something else ?

(anyway, many thanks for your help)

Last edit: 14 years 10 months ago by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

14 years 10 months ago [\#31550](#31550) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31550 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

That's indeed what I meant.

You should put a trace directly at the beginning of your function onAfterOrderUpdate(&amp;$order,&amp;$send_email) like that:
echo "test"; exit;

that way, you will see the "test" message if the plugin is triggered. If it is not triggered, then the only option is that the plugin is not published which should not be the case since you say that it works with other tests.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")**
- [![ursule15's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4747-ursule15 "View ursule15's Profile")
- [ Offline](/forum/user/4747-ursule15)

Less More

- Posts: 10
- Thank you received: 0
-
-

14 years 10 months ago -  14 years 10 months ago [\#31567](#31567) by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")  Replied by *[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31567 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

I am using jdump to check.
And I confirm, when creating an order with confirmed status as default status on bank transfer, onAfterOrderCreate is triggered once, onAfterOrderUpdate is triggered twice.

But my sql DB is not updated this way, even if th code is working well when updating manually.
Something is wrong in my code, not same variable I guess when updating manually.

I will check.
Many thanks for your help.

edit :

OK, I can see why it is not working.
in the code, I need the userid.
I am using the following :
$orderClass = hikashop::get('class.order');
$dbOrder = $orderClass-&gt;get($order-&gt;order_id);
$orderClass=$orderClass-&gt;loadFullOrder($order-&gt;order_id, false, false);

Then $orderClass-&gt;customer-&gt;id is the userid.

This code works when manually changing the status.
But it does not work when the order is created the proper way (by the user, frontend side, bank transfer payment).

There is no customer property for $orderClass.

What do I miss here ?

Last edit: 14 years 10 months ago by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

14 years 10 months ago [\#31586](#31586) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31586 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

The customer is indeed only loaded in $orderClass when on the back end.

You should add these lines:
$userClass = hikashop_get('class.user');
$orderClass-&gt;customer = $userClass-&gt;get($orderClass-&gt;order_user_id);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")**
- [![ursule15's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4747-ursule15 "View ursule15's Profile")
- [ Offline](/forum/user/4747-ursule15)

Less More

- Posts: 10
- Thank you received: 0
-
-

14 years 10 months ago -  14 years 10 months ago [\#31604](#31604) by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")  Replied by *[ursule15](/forum/user/4747-ursule15 "View ursule15's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31604 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

Hello,

I tried your piece of code (just modified hikashop_get to hikasho::get).
But $userClass-&gt;get($orderClass-&gt;order_user_id) return null (even if $userClass seems to be correctly created before).

I think I need to learn a bit more about php before trying to understand all of this (totally noob regarding this language).

Last edit: 14 years 10 months ago by [ursule15](/forum/user/4747-ursule15 "View ursule15's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86292
- Thank you received: 14271
-
-

14 years 10 months ago [\#31616](#31616) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: add data to a table after order is confirmed](/forum/4-how-to/14389-add-data-to-a-table-after-order-is-confirmed#31616 "I'd like to be able to add some data to fields in 1 table in my database whenever a payment is verified and order becomes confirmed. where can I do that?")*

If that code returns null it means that either $orderClass-&gt;order_user_id does not contain the user id or that the user has been deleted in HikaShop.
So you should look at that.
hikashop_get won't work in old versions of HikaShop and in that case you should use hikashop::get instead.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzE0Mzg5LWFkZC1kYXRhLXRvLWEtdGFibGUtYWZ0ZXItb3JkZXItaXMtY29uZmlybWVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.495 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
