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

#   Update user profile based on items ordered

##

- **[jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")**
- [![jfischer&#95;hika's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile") Topic Author
- [ Offline](/forum/user/60459-jfischer-hika)

Less More

- Posts: 51
- Thank you received: 3
-
-

2 years 3 months ago [\#362212](#362212) by [jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")  *[Update user profile based on items ordered](/forum/31-development/908416-update-user-profile-based-on-items-ordered#362212 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.0.3 -- PHP version -- : 8.2  I am creating a plugin to update my user profile based on items ordered.  I am using the onAfterOrderCreate trigger to execute my code. This seems to work fine when an order is created by the front end, but I noticed when creating an order from the back end, there is no product information in the $order array.  From the front end order, I have the $order-&gt;products array to get the item information. When the order is created from the back end, the onAfterOrderCreate is called before the products are added, so no product information is retrieved.  I can query the hikashop&#95;order&#95;product with the order&#95;id to get what I need, but I need a trigger that fires after the products are added via the backend form.  Is there a better method to use?")* was created by *[jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")*

-- HikaShop version -- : 5.1.0
-- Joomla version -- : 5.0.3
-- PHP version -- : 8.2

I am creating a plugin to update my user profile based on items ordered.

I am using the onAfterOrderCreate trigger to execute my code. This seems to work fine when an order is created by the front end, but I noticed when creating an order from the back end, there is no product information in the $order array.

From the front end order, I have the $order-&gt;products array to get the item information. When the order is created from the back end, the onAfterOrderCreate is called before the products are added, so no product information is retrieved.

I can query the hikashop_order_product with the order_id to get what I need, but I need a trigger that fires after the products are added via the backend form.

Is there a better method to use?

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

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

2 years 3 months ago [\#362215](#362215) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Update user profile based on items ordered](/forum/31-development/908416-update-user-profile-based-on-items-ordered#362215 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.0.3 -- PHP version -- : 8.2  I am creating a plugin to update my user profile based on items ordered.  I am using the onAfterOrderCreate trigger to execute my code. This seems to work fine when an order is created by the front end, but I noticed when creating an order from the back end, there is no product information in the $order array.  From the front end order, I have the $order-&gt;products array to get the item information. When the order is created from the back end, the onAfterOrderCreate is called before the products are added, so no product information is retrieved.  I can query the hikashop&#95;order&#95;product with the order&#95;id to get what I need, but I need a trigger that fires after the products are added via the backend form.  Is there a better method to use?")*

Hello,

Because "onAfterOrderCreate" is triggered when an order is created, it means that the order has mostly the "created" status and is not yet confirmed.
On the backend, when you create a new order, the order is fully empty, meaning that there is no user (yet).
Thus, the trigger is called in the backend but because that order is empty, you can't check the user nor the ordered items (there are none).

That's why, most of plugins are using the trigger "onAfterOrderUpdate" and check that the "order_status" is changing (between the current and the $order-&gt;old) to a "confirmed" status.
It allows to perform an action when you know that the order is beeing paid/confirmed ; and you can do the opposite actions when an order is refunded (leaving the "confirmed" statuses, to another group of order status).

By doing that, you will be also compatbile with the backend since you will create an order order, assign a user, add products and then changing the order status to "created" to "confirmed".

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

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

- **[jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")**
- [![jfischer&#95;hika's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile") Topic Author
- [ Offline](/forum/user/60459-jfischer-hika)

Less More

- Posts: 51
- Thank you received: 3
-
-

2 years 3 months ago [\#362254](#362254) by [jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")  Replied by *[jfischer\_hika](/forum/user/60459-jfischer-hika "View jfischer&#95;hika's Profile")* on topic *[Update user profile based on items ordered](/forum/31-development/908416-update-user-profile-based-on-items-ordered#362254 "-- HikaShop version -- : 5.1.0 -- Joomla version -- : 5.0.3 -- PHP version -- : 8.2  I am creating a plugin to update my user profile based on items ordered.  I am using the onAfterOrderCreate trigger to execute my code. This seems to work fine when an order is created by the front end, but I noticed when creating an order from the back end, there is no product information in the $order array.  From the front end order, I have the $order-&gt;products array to get the item information. When the order is created from the back end, the onAfterOrderCreate is called before the products are added, so no product information is retrieved.  I can query the hikashop&#95;order&#95;product with the order&#95;id to get what I need, but I need a trigger that fires after the products are added via the backend form.  Is there a better method to use?")*

That works for me.

Thank you

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

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