Accessing Order-id after order created.

  • Posts: 256
  • Thank you received: 21
7 years 8 months ago #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 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->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 or Create an account to join the conversation.

  • Posts: 256
  • Thank you received: 21
7 years 8 months ago #264202

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

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

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
7 years 8 months ago #264209

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

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum