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

#   Accessing Order-id after order created.

##

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

Less More

- Posts: 259
- Thank you received: 22
-
-

9 years 8 months ago [\#264199](#264199) by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")  *[Accessing Order-id after order created.](/forum/27-checkout/889204-accessing-order-id-after-order-created#264199 "I have an SAP integration where the contents of an order are passed to an SAP server by a System Plugin when the order is saved. To complicate matters the Joomla site is accessed from the customers...")* was created by *[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")*

I have an SAP integration where the contents of an order are passed to an SAP server by a System Plugin when the order is saved. To complicate matters the Joomla site is accessed from the customers purchasing system which uses the same login account for all orders and multiple employees can be creating orders at the same time. This is OK because all orders are kept separate by the session id.

Here is my problem. Currently the system plugin gets the order details by calling up the last order id for the customer which works 99% of the time but occasionally returns the wrong details when two order are created simultaneously. When I use $this-&gt;order nothing is returned as it seems the variable has already been removed. What is the best way to keep the order_id as a global or session variable so it is available after the order is created? ie. What file would I declare this in and in what format?

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

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

Less More

- Posts: 259
- Thank you received: 22
-
-

9 years 8 months ago [\#264202](#264202) by [rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")  Replied by *[rodfarrell](/forum/user/5859-rodfarrell "View rodfarrell's Profile")* on topic *[Accessing Order-id after order created.](/forum/27-checkout/889204-accessing-order-id-after-order-created#264202 "I have an SAP integration where the contents of an order are passed to an SAP server by a System Plugin when the order is saved. To complicate matters the Joomla site is accessed from the customers...")*

Found it. The code below seems to do the job.

$app =&amp; JFactory::getApplication();
$order_id = $app-&gt;getUserState('com_hikashop.order_id');

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg4OTIwNC1hY2Nlc3Npbmctb3JkZXItaWQtYWZ0ZXItb3JkZXItY3JlYXRlZD90bXBsPW1hcmtkb3du) 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: 86587
- Thank you received: 14326
-
-

9 years 8 months ago [\#264209](#264209) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Accessing Order-id after order created.](/forum/27-checkout/889204-accessing-order-id-after-order-created#264209 "I have an SAP integration where the contents of an order are passed to an SAP server by a System Plugin when the order is saved. To complicate matters the Joomla site is accessed from the customers...")*

Hi,

Yes, you can use that code.
Note that normally, you can use the trigger onAfterOrderCreate which provides the variable $order with all the order details, including the order_id in your plugin:
[ www.hikashop.com/support/documentation/6...l#onAfterOrderCreate](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#onAfterOrderCreate)

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

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