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

#   Using onAfterOrderUpdate in administrator backend

##

- **[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 6 months ago [\#316799](#316799) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  *[Using onAfterOrderUpdate in administrator backend](/forum/31-development/899394-using-onafterorderupdate-in-administrator-backend#316799 "-- HikaShop version -- : 3.5.1 -- Joomla version -- : 3.8.2 -- PHP version -- : 7.1  Hi, I've been trying to create a function when admin modifies a order from backend, and I've had no luck.. I've tried using variations of below code in order.php (classes and controllers) any help would be appreciate! ( I want to create a function when admin cancels an order, needs to send an API to outside affiliate) Thanks!  function onAfterOrderUpdate (&amp;$order,&amp;$send&#95;email) { var&#95;dump('ahasdh'); exit; $config =&amp; hikashop&#95;config(); $confirmed = $config-&gt;get('order&#95;confirmed&#95;status'); $orderClass = hikashop&#95;get('class.order'); $orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order&#95;id); if (!isset ($order-&gt;order&#95;status)) return true; if ($order-&gt;order&#95;status = $confirmed) { return true; }  if ($order-&gt;order&#95;status == $confirmed) {  // my simple action to test } }")* was created by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")*

-- HikaShop version -- : 3.5.1
-- Joomla version -- : 3.8.2
-- PHP version -- : 7.1

Hi, I've been trying to create a function when admin modifies a order from backend, and I've had no luck.. I've tried using variations of below code in order.php (classes and controllers) any help would be appreciate! ( I want to create a function when admin cancels an order, needs to send an API to outside affiliate) Thanks!

function onAfterOrderUpdate (&amp;$order,&amp;$send_email) {
var_dump('ahasdh'); exit;
$config =&amp; hikashop_config();
$confirmed = $config-&gt;get('order_confirmed_status');
$orderClass = hikashop_get('class.order');
$orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order_id);
if (!isset ($order-&gt;order_status))
return true;
if ($order-&gt;order_status = $confirmed) {
return true;
}

if ($order-&gt;order_status == $confirmed) {

// my simple action to test
}
}

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTM5NC11c2luZy1vbmFmdGVyb3JkZXJ1cGRhdGUtaW4tYWRtaW5pc3RyYXRvci1iYWNrZW5kP3RtcGw9bWFya2Rvd24=) 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 6 months ago [\#316802](#316802) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Using onAfterOrderUpdate in administrator backend](/forum/31-development/899394-using-onafterorderupdate-in-administrator-backend#316802 "-- HikaShop version -- : 3.5.1 -- Joomla version -- : 3.8.2 -- PHP version -- : 7.1  Hi, I've been trying to create a function when admin modifies a order from backend, and I've had no luck.. I've tried using variations of below code in order.php (classes and controllers) any help would be appreciate! ( I want to create a function when admin cancels an order, needs to send an API to outside affiliate) Thanks!  function onAfterOrderUpdate (&amp;$order,&amp;$send&#95;email) { var&#95;dump('ahasdh'); exit; $config =&amp; hikashop&#95;config(); $confirmed = $config-&gt;get('order&#95;confirmed&#95;status'); $orderClass = hikashop&#95;get('class.order'); $orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order&#95;id); if (!isset ($order-&gt;order&#95;status)) return true; if ($order-&gt;order&#95;status = $confirmed) { return true; }  if ($order-&gt;order&#95;status == $confirmed) {  // my simple action to test } }")*

Hi,

You need to place that code inside a Joomla plugin of the group "hikashop".
Here, you can find information on how to build Joomla plugins:
[ docs.joomla.org/Portal:Plugin\_Development](http://docs.joomla.org/Portal:Plugin_Development)
And here, you can see what the PHP code can look like for a Joomla plugin of the group "hikashop":
[ www.hikashop.com/support/documentation/6...mentation.html#howto](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#howto)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTM5NC11c2luZy1vbmFmdGVyb3JkZXJ1cGRhdGUtaW4tYWRtaW5pc3RyYXRvci1iYWNrZW5kP3RtcGw9bWFya2Rvd24=) 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 6 months ago [\#316822](#316822) by [nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")  Replied by *[nozaro33](/forum/user/45757-nozaro33 "View nozaro33's Profile")* on topic *[Using onAfterOrderUpdate in administrator backend](/forum/31-development/899394-using-onafterorderupdate-in-administrator-backend#316822 "-- HikaShop version -- : 3.5.1 -- Joomla version -- : 3.8.2 -- PHP version -- : 7.1  Hi, I've been trying to create a function when admin modifies a order from backend, and I've had no luck.. I've tried using variations of below code in order.php (classes and controllers) any help would be appreciate! ( I want to create a function when admin cancels an order, needs to send an API to outside affiliate) Thanks!  function onAfterOrderUpdate (&amp;$order,&amp;$send&#95;email) { var&#95;dump('ahasdh'); exit; $config =&amp; hikashop&#95;config(); $confirmed = $config-&gt;get('order&#95;confirmed&#95;status'); $orderClass = hikashop&#95;get('class.order'); $orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order&#95;id); if (!isset ($order-&gt;order&#95;status)) return true; if ($order-&gt;order&#95;status = $confirmed) { return true; }  if ($order-&gt;order&#95;status == $confirmed) {  // my simple action to test } }")*

Many Thanks!
Another question if that's ok, I need to store 3rd party affiliate info into the order, what suggested methods would there be? After onOrderConfirm? Is it possible to use cookies when writing functions? Thanks! (Because API info must only be sent if the 3rd party affiliate cookie exists)
Thanks!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5OTM5NC11c2luZy1vbmFmdGVyb3JkZXJ1cGRhdGUtaW4tYWRtaW5pc3RyYXRvci1iYWNrZW5kP3RtcGw9bWFya2Rvd24=) 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 6 months ago [\#316826](#316826) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Using onAfterOrderUpdate in administrator backend](/forum/31-development/899394-using-onafterorderupdate-in-administrator-backend#316826 "-- HikaShop version -- : 3.5.1 -- Joomla version -- : 3.8.2 -- PHP version -- : 7.1  Hi, I've been trying to create a function when admin modifies a order from backend, and I've had no luck.. I've tried using variations of below code in order.php (classes and controllers) any help would be appreciate! ( I want to create a function when admin cancels an order, needs to send an API to outside affiliate) Thanks!  function onAfterOrderUpdate (&amp;$order,&amp;$send&#95;email) { var&#95;dump('ahasdh'); exit; $config =&amp; hikashop&#95;config(); $confirmed = $config-&gt;get('order&#95;confirmed&#95;status'); $orderClass = hikashop&#95;get('class.order'); $orderInDb = $orderClass-&gt;loadFullOrder($order-&gt;order&#95;id); if (!isset ($order-&gt;order&#95;status)) return true; if ($order-&gt;order&#95;status = $confirmed) { return true; }  if ($order-&gt;order&#95;status == $confirmed) {  // my simple action to test } }")*

Hi,

In that case, you can use the onBeforeOrderCreate(&amp;$order, &amp;$do) trigger.
You could first create a custom field of the table "order" so that you could store the information you want in that column of the hikashop_order table.
Then, you can check the cookies of the customer in that trigger with the $_COOKIE PHP global array:
[ www.php.net/manual/en/reserved.variables.cookies.php](https://www.php.net/manual/en/reserved.variables.cookies.php)
[ www.tutorialrepublic.com/php-tutorial/php-cookies.php](https://www.tutorialrepublic.com/php-tutorial/php-cookies.php)

And in the onBeforeOrderCreate function of your plugin, you can just have that code:
$order-&gt;xxx = $var;
where xxx is the column name of your custom field and $var contains the string you want to store. HikaShop will save your data for you automcatically since your code will be just before the saving process.

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

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

[](#top)
