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

#   onAfterOrderUpdate not show Cart object

##

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

Less More

- Posts: 221
- Thank you received: 8
-

4 years 3 months ago [\#343811](#343811) by [sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")  *[onAfterOrderUpdate not show Cart object](/forum/31-development/904833-onafterorderupdate-not-show-cart-object#343811 "-- HikaShop version -- : 4.4.5  hi i have two different site with hikashop and i write some code in history plugin . in one of that it is work and in other it is not work. when i dump for show all inside $order the first(hika 4.4.2) return Cart and the second(hika4.4.5) not return Cart. look at picture.")* was created by *[sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")*

-- HikaShop version -- : 4.4.5

hi
i have two different site with hikashop and i write some code in history plugin . in one of that it is work and in other it is not work.
when i dump for show all inside $order the first(hika 4.4.2) return Cart and the second(hika4.4.5) not return Cart. look at picture.
[ ![2022-08-10&#95;21-53-13.png](/forum/attachment/55357) ](/forum/attachment/55357 "...0&#95;21-53-13.png")

- [ ![2022-08-10&#95;21-53-13.png](/forum/attachment/55357) ](/forum/attachment/55357 "...0&#95;21-53-13.png") [ ](/forum/attachment/55357?download=1 "...0&#95;21-53-13.png")

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

Less More

- Posts: 86541
- Thank you received: 14304
-
-

4 years 3 months ago [\#343815](#343815) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[onAfterOrderUpdate not show Cart object](/forum/31-development/904833-onafterorderupdate-not-show-cart-object#343815 "-- HikaShop version -- : 4.4.5  hi i have two different site with hikashop and i write some code in history plugin . in one of that it is work and in other it is not work. when i dump for show all inside $order the first(hika 4.4.2) return Cart and the second(hika4.4.5) not return Cart. look at picture.")*

Hi,

Like all the "update" events, the onAfterOrderUpdate's first parameter contains the data being saved in the database.
This depends on what the code calling the class.order's save method provided.
To update an order the minimum required is to provide the order_id. For example: Code:

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

This will provide to the onAfterOrderUpdate event with an object with 4 things:
- the old attribute which contains an object of the order data in the database before the data in the database was updated
- the history attribute, which contains a history object with generic information going into the "history" table for that order
- the order_id that the code set in $order to target the corresponding order
- the order_modified which contains the current unix timestamp to be saved in the database
That's the only things you'll always have in that first parameter of onAfterOrderUpdate. Anything else is added or not by the code calling the save function and as a plugin implementing the event you have no guarantee that they will be provided.

The "cart" attribute might be available when an order is updated in the same thread as it's being created, or it might be set by the email system when the email tags are being generated. You can rely on that attribute being always present in the first parameter of the event. If it's added by the emails and you disable the emails in System&gt;Emails, then the cart attribute wouldn't be provided for example. And if you run a mass action to update orders, the emails won't be sent and that attribute won't be there either.

Note however that the cart attribute is just the data returned by loadFullOrder
So you could just have that code at the beginning of your code: Code:

if(empty($order-&gt;cart)) { $orderClass = hikashop_get('class.order'); $order-&gt;cart = $orderClass-&gt;loadFullOrder($order-&gt;order_id, false, false); }

The following user(s) said Thank You: [sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")

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

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