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

#   Order status hook

##

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

Less More

- Posts: 75
- Thank you received: 4
-
-

3 years 7 months ago [\#351009](#351009) by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")  *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351009 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")* was created by *[Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")*

-- HikaShop version -- : 4.7.2
-- Joomla version -- : 4.2.9
-- PHP version -- : 8.0

I have some questions about order statuses, and payments.

I made a new order status called "parcel ready".
Questions:
1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to "parcel ready" then call a php file which sends the data to the company.
I would need it when the payment method is wire transfer.
2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.

Where should I implement the changes (ideally one place in the code) to make it work?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

3 years 7 months ago [\#351010](#351010) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351010 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Hi,

You want to develop a small plugin of the group "hikashop" and implement the onAfterOrderUpdate(&amp;$order,&amp;$send_email) event:
[ www.hikashop.com/support/documentation/6...#onBeforeOrderUpdate](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onBeforeOrderUpdate)
This event is called each time something is changed in an order, including the order_status.
So you want to check $order-&gt;order_status and $order-&gt;old-&gt;order_status and based on this, make the call to the API.
For example: Code:

class plgHikashopName extends JPlugin { function plgHikashopName(&amp;$subject, $config){ parent::__construct($subject, $config); } function onAfterOrderUpdate(&amp;$order, &amp;$send_email) { // order status is not being changed if(empty($order-&gt;order_status)) return true; // order status is not being changed to "parcel ready" if($order-&gt;order_status!="parcel ready") return true; // order status was already before "parcel ready" if($order-&gt;order_status == $order-&gt;old-&gt;order_status) return true; // call the API } }

I recommend doing it as a plugin. That way, you won't have anything to do each time you update HikaShop and this API will probably never change in the future, meaning that the plugin will work with future versions of HikaShop without doing anything.

The following user(s) said Thank You: [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")

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

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

Less More

- Posts: 75
- Thank you received: 4
-
-

3 years 7 months ago [\#351018](#351018) by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")  Replied by *[Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351018 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

This sounds good...thanks
And can I trigger it somehow when the customer pays with card and the transaction is successful?

I would need to change the status in the payment plugin and trigger this event.
I have the succesful payment part of the payment plugin...

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

3 years 7 months ago [\#351020](#351020) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351020 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Hi,

When the customers pays with card and the transaction is successful, the payment gateway you're using will normally send an HTTP request to the payment plugin on your website, which will verify it and change the status of the order from "created" to "confirmed". And when it does that, it normally goes through the order save procedure in HikaShop which triggers the onAfterOrderUpdate event I was talking about above.
So normally, the onAfterOrderUpdate event should already be triggered in your plugin when this happens without doing anything special.

The following user(s) said Thank You: [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")

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

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

Less More

- Posts: 75
- Thank you received: 4
-
-

3 years 7 months ago [\#351026](#351026) by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")  Replied by *[Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351026 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

How can I debug / try things like var_dump? What you wrote example is owrking, I can see, but tried to have a look what the $order object contains, but as it displays in a popup disappear in a second when I change the status.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

3 years 7 months ago [\#351027](#351027) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351027 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Hi,

Add Code:

exit;

after the var_dump. It will stop the processing and should display the var_dump in the popup without it closing.

Also, HikaShop has a function hikashop_writeToLog($data)
When you call that function, it will store the content of $data in the "payment log file" you can access under the Main tab of the HikaShop configuration. So it's a great way to debug things where you don't have a way to display things to the browser.
For example, when the payment gateway calls the payment plugin to notify it of the payment, this usually happens in a server-to-server way and thus if you var_dump something in the payment plugin, or a plugin acting upon the order status change, it will be output to the payment gateway server. So using hikashop_writeToLog() comes in handy.

The following user(s) said Thank You: [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")

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

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

Less More

- Posts: 75
- Thank you received: 4
-
-

3 years 6 months ago [\#351264](#351264) by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")  Replied by *[Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351264 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

How can I get all the order details inside the onAfterOrderUpdate function?
I need the billing, shipping details but looks like it doesn't have these...

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

3 years 6 months ago [\#351271](#351271) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#351271 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Hi,

Indeed, in onAfterOrderUpdate you only get in $order what the thing saving the order is providing, not the complete order.
So if you need the complete order information, you can use : Code:

$orderClass = hikashop_get('class.order'); $fullOrder = $orderClass-&gt;loadFullOrder($order-&gt;order_id, true, false);

And you'll get everything in $fullOrder

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

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

Less More

- Posts: 75
- Thank you received: 4
-
-

3 years 3 months ago -  3 years 3 months ago [\#354354](#354354) by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")  Replied by *[Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#354354 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Can I change order status in the plugin?
I use the onAfterOrderCreate(&amp;$order) fuunction to connect the hikshop with the billing software.
Can I set the order status from "created" to "invoice_sent" when it returns true?
If so, does it run the onAfterOrderUpdate event or not?

Last edit: 3 years 3 months ago by [Petike1007](/forum/user/12229-petike1007 "View Petike1007's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14324
-
-

3 years 3 months ago [\#354356](#354356) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Order status hook](/forum/35-orders-management/906260-order-status-hook#354356 "-- HikaShop version -- : 4.7.2 -- Joomla version -- : 4.2.9 -- PHP version -- : 8.0  I have some questions about order statuses, and payments.  I made a new order status called &quot;parcel ready&quot;. Questions: 1. When I choose this status, is there any hook which I can use to call an API to the shipping company. So I can check if the shipping company is myshippingcompany and the status is changed to &quot;parcel ready&quot; then call a php file which sends the data to the company. I would need it when the payment method is wire transfer. 2. Also when the payment is through an online service and come back as completed I would need to call the same method automatically.  Where should I implement the changes (ideally one place in the code) to make it work?")*

Hi,

Yes you can use that code: Code:

$newObject = new stdClass(); $newObject-&gt;order_id = $order-&gt;order_id; $newObject-&gt;order_status = 'invoice_sent'; $orderClass = hikashop_get('class.order'); $orderClass-&gt;save($newObject);

This will silently (no email will be sent) change the order status.
And yes, onAfterOrderUpdate will be triggered.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkwNjI2MC1vcmRlci1zdGF0dXMtaG9vaz90bXBsPW1hcmtkb3du) 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.125 seconds

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