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

#   Quick onAfterOrderConfirm question

##

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 5 months ago [\#319606](#319606) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319606 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")* was created by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")*

I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?

function onAfterOrderConfirm(&amp;$order){
//Run my SMS code here
}

Thanks so much

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTk1NC1xdWljay1vbmFmdGVyb3JkZXJjb25maXJtLXF1ZXN0aW9uP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

6 years 5 months ago [\#319608](#319608) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319608 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

Hi,

No that trigger is called after the checkout for the payment method selected so that it can redirect to the payment gateway.
What you want to do is to implement instead the "onAfterOrderUpdate" trigger and check the $order-&gt;order_status and the $order-&gt;old-&gt;order_status so that you can see the order is going from "created" to "confirmed" and then run your code.
Doing it like this will indeed work regardless of the payment method being used (unless the payment plugin directly creates the order as confirmed, in that case, you'll want to also implement the onAfterOrderCreate trigger and check the order status in $order-&gt;order_status).
When we develop such plugin to act upon an order being paid, we usually implement both the onAfterOrderUpdate and onAfterOrderCreate so that we can take into account all the ways different payment plugins can work.

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 5 months ago [\#319619](#319619) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319619 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

Got it, thanks so much!

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 4 months ago [\#319755](#319755) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319755 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

so if payment plugin sends back payment confirmation change order to confim, onAfterOrderUpdate the trigger should be
if( $order-&gt;old-&gt;order_status =='created' &amp;&amp; $order-&gt;order_status == 'confirmed') correct?

But if I have a trigger that is order_status == confirm (and ignore the -&gt;old-&gt;order_status, then the function would be sent twice if an admin changed the order created -&gt; to confirmed manually from back end. I hope I'm making sense...

Thanks!

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 4 months ago [\#319756](#319756) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319756 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

also, it works for manual backend set to confirm, but if payment gateway sends back confirmation after paid and order status is changed to confirm, the plugin doesn't work

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTk1NC1xdWljay1vbmFmdGVyb3JkZXJjb25maXJtLXF1ZXN0aW9uP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

6 years 4 months ago [\#319776](#319776) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319776 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

Hi,

The plugin will also be triggered for the onAfterOrderUpdate when the payment plugin changes the status of the order to confirmed after the payment. That is unless the payment plugin isn't coded properly.
Note however that in such case, the order confirmation usually happens with a direct request from the payment gateway server to your server. So as a customer you don't see anything on the interface.
If you want to check that the trigger is called in such case, you need to write text in a file and then check that file content.

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 4 months ago [\#319804](#319804) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319804 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

Thank you, I found out the problem is payment notification can't run " $orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order_id); "
that's correct right?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTk1NC1xdWljay1vbmFmdGVyb3JkZXJjb25maXJtLXF1ZXN0aW9uP3RtcGw9bWFya2Rvd24=) 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")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86289
- Thank you received: 14265
-
-

6 years 4 months ago [\#319809](#319809) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319809 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

Hi,

Well, yes and no.
If you call it like that, it will only work if the current user session is the owner of the order.
Otherwise, if you want to load the data regardless, you want to do like that :
$orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order_id, false, false);
That will deactivate the check of the user.

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

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

Less More

- Posts: 11
- Thank you received: 0
-
-

6 years 4 months ago [\#319829](#319829) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Quick onAfterOrderConfirm question](/forum/31-development/899954-quick-onafterorderconfirm-question#319829 "I want to run code that after order confirm sends SMS, I can directly use this trigger without caring what payment gateway it is correct?  function onAfterOrderConfirm(&amp;$order){ //Run my SMS code here }  Thanks so much")*

I get it now, thanks!

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

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

[](#top)
