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

#   How to save order details in a plugin

##

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

Less More

- Posts: 45
- Thank you received: 0
-
-

11 years 9 months ago -  11 years 9 months ago [\#187787](#187787) by [paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile")  *[How to save order details in a plugin](/forum/31-development/874445-how-to-save-order-details-in-a-plugin#187787 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hi,  I'm making a new payment plugin. In onOrderAfterConfirmation the payment portal generates a transaction ID that I want/need to store with the order. I tried the following:  &#42; Add the transaction ID to $order-&gt;order&#95;payment&#95;params. Nothing is saved.  &#42; Add the transaction ID, and call $order-&gt;save($order). White screen, function not found apparently.  &#42; Add the transaction ID, create a dummy order to have access to the save method. This works, but now I get an SQL error that I want to inject fields that are not in the database.  &#42; Add the transaction ID, and copy all fields whose names start with 'order&#95;' to a new object, and try to save that one. A SQL error occurs again, that still some fields are not in the database.  OK, I think I can make this work, but I was asking myself whether there is a smarter way to accomplish this.  Your help is appreciated.  Best regards, Paul")* was created by *[paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile")*

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6

Hi,

I'm making a new payment plugin. In onOrderAfterConfirmation the payment portal generates a transaction ID that I want/need to store with the order.
I tried the following:

1. Add the transaction ID to $order-&gt;order\_payment\_params. Nothing is saved.
2. Add the transaction ID, and call $order-&gt;save($order). White screen, function not found apparently.
3. Add the transaction ID, create a dummy order to have access to the save method. This works, but now I get an SQL error that I want to inject fields that are not in the database.
4. Add the transaction ID, and copy all fields whose names start with 'order\_' to a new object, and try to save that one. A SQL error occurs again, that still some fields are not in the database.

OK, I think I can make this work, but I was asking myself whether there is a smarter way to accomplish this.

Your help is appreciated.

Best regards, Paul

Last edit: 11 years 9 months ago by [paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile").

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

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

11 years 9 months ago [\#187800](#187800) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[How to save order details in a plugin](/forum/31-development/874445-how-to-save-order-details-in-a-plugin#187800 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hi,  I'm making a new payment plugin. In onOrderAfterConfirmation the payment portal generates a transaction ID that I want/need to store with the order. I tried the following:  &#42; Add the transaction ID to $order-&gt;order&#95;payment&#95;params. Nothing is saved.  &#42; Add the transaction ID, and call $order-&gt;save($order). White screen, function not found apparently.  &#42; Add the transaction ID, create a dummy order to have access to the save method. This works, but now I get an SQL error that I want to inject fields that are not in the database.  &#42; Add the transaction ID, and copy all fields whose names start with 'order&#95;' to a new object, and try to save that one. A SQL error occurs again, that still some fields are not in the database.  OK, I think I can make this work, but I was asking myself whether there is a smarter way to accomplish this.  Your help is appreciated.  Best regards, Paul")*

Hi,

To add a value to the order, I think that the easiest way will be to create a custom field in the order table.
This way it will add a column in the database, and you will just have to add the value to $order-&gt;CUSTOMFIELD_NAME and save the order.

To use the "save" function you need to call the order class before: Code:

$orderClass = hikashop_get('class.order'); if(isset($order-&gt;CUSTOMFIELD_NAME)){ $order-&gt;CUSTOMFIELD_NAME = $transaction_id; } $orderClass-&gt;save($order);

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

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

Less More

- Posts: 45
- Thank you received: 0
-
-

11 years 9 months ago -  11 years 9 months ago [\#187930](#187930) by [paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile")  Replied by *[paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile")* on topic *[How to save order details in a plugin](/forum/31-development/874445-how-to-save-order-details-in-a-plugin#187930 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hi,  I'm making a new payment plugin. In onOrderAfterConfirmation the payment portal generates a transaction ID that I want/need to store with the order. I tried the following:  &#42; Add the transaction ID to $order-&gt;order&#95;payment&#95;params. Nothing is saved.  &#42; Add the transaction ID, and call $order-&gt;save($order). White screen, function not found apparently.  &#42; Add the transaction ID, create a dummy order to have access to the save method. This works, but now I get an SQL error that I want to inject fields that are not in the database.  &#42; Add the transaction ID, and copy all fields whose names start with 'order&#95;' to a new object, and try to save that one. A SQL error occurs again, that still some fields are not in the database.  OK, I think I can make this work, but I was asking myself whether there is a smarter way to accomplish this.  Your help is appreciated.  Best regards, Paul")*

Dear Xavier,

Thank you for looking into this. Your suggestion is nearly the same as my attempt #3. Instead of adding it as a field to the database, I want to store my data in the params structure. The mechanics for that are already available.

Your code Code:

$orderClass-&gt;save($order);

will suffer from the same issues as mine, that in other parts of the checkout process data has been added to this object, that are not reflected in the database. Therefore, you're code will also issue an SQL error.

Last edit: 11 years 9 months ago by [paulvanharen](/forum/user/20480-paulvanharen "View paulvanharen's Profile").

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

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

11 years 9 months ago [\#187977](#187977) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[How to save order details in a plugin](/forum/31-development/874445-how-to-save-order-details-in-a-plugin#187977 "-- HikaShop version -- : 2.3.5 -- Joomla version -- : 3.3.6  Hi,  I'm making a new payment plugin. In onOrderAfterConfirmation the payment portal generates a transaction ID that I want/need to store with the order. I tried the following:  &#42; Add the transaction ID to $order-&gt;order&#95;payment&#95;params. Nothing is saved.  &#42; Add the transaction ID, and call $order-&gt;save($order). White screen, function not found apparently.  &#42; Add the transaction ID, create a dummy order to have access to the save method. This works, but now I get an SQL error that I want to inject fields that are not in the database.  &#42; Add the transaction ID, and copy all fields whose names start with 'order&#95;' to a new object, and try to save that one. A SQL error occurs again, that still some fields are not in the database.  OK, I think I can make this work, but I was asking myself whether there is a smarter way to accomplish this.  Your help is appreciated.  Best regards, Paul")*

Hello,
Note that checking the "modifyOrder" function of the "administrator\components\com_hikashop\helpers\helper.php" file will probably help you, note that you can save your order using the save function of the $orderClass, but you can also save some extra data via "$order-&gt;history-&gt;history_data".

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

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