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

#   How to store transaction id in hikashop order table as a new field

##

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

Less More

- Posts: 21
- Thank you received: 0
-
-

6 years 4 months ago [\#321534](#321534) by [ajdev33](/forum/user/59738-ajdev33 "View ajdev33's Profile")  *[How to store transaction id in hikashop order table as a new field](/forum/35-orders-management/900317-how-to-store-transaction-id-in-hikashop-order-table-as-a-new-field#321534 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.3  I am working on a custom third party payment plugin. I have installed it and have implemented code to redirect on payment page and back on shop successfully. Now I want to store transaction id retrieved from payment gateway in order table as a new field.  I don't know how to store/add transaction id in order table.  I tried below code, but it is also not working.  So if anyone can help me out from this would be very helpful for me.  Thanks")* was created by *[ajdev33](/forum/user/59738-ajdev33 "View ajdev33's Profile")*

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.19
-- PHP version -- : 7.3

I am working on a custom third party payment plugin. I have installed it and have implemented code to redirect on payment page and back on shop successfully. Now I want to store transaction id retrieved from payment gateway in order table as a new field.

I don't know how to store/add transaction id in order table.

I tried below code, but it is also not working.
Code:

$orderClass = hikashop_get('class.order'); $order = $orderClass-&gt;get($order_id); if(isset($order-&gt;custom_auth_number)){ $order-&gt;custom_auth_number = $authNumber; } if(isset($order-&gt;custom_txn_id)){ $order-&gt;custom_txn_id = $transactionId; } $orderClass-&gt;save($order);

So if anyone can help me out from this would be very helpful for me.

Thanks

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

Less More

- Posts: 86583
- Thank you received: 14324
-
-

6 years 4 months ago [\#321549](#321549) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to store transaction id in hikashop order table as a new field](/forum/35-orders-management/900317-how-to-store-transaction-id-in-hikashop-order-table-as-a-new-field#321549 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.3  I am working on a custom third party payment plugin. I have installed it and have implemented code to redirect on payment page and back on shop successfully. Now I want to store transaction id retrieved from payment gateway in order table as a new field.  I don't know how to store/add transaction id in order table.  I tried below code, but it is also not working.  So if anyone can help me out from this would be very helpful for me.  Thanks")*

Hi,

This should be fine. However, I would recommend to only add the attributes you want in the $order object, like this: Code:

$orderClass = hikashop_get('class.order'); $order = new stdClass(); $order-&gt;order_id = $order_id; $order-&gt;custom_auth_number = $authNumber; $order-&gt;custom_txn_id = $transactionId; $orderClass-&gt;save($order);

Note that you first need to have the columns custom_auth_number and custom_txn_id in the hikashop_order table.
If you don't, the MySQL query will crash.
So you first want to do an ALTER on that table to add these columns if you don't already have them.

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

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

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

Less More

- Posts: 21
- Thank you received: 0
-
-

6 years 4 months ago [\#321564](#321564) by [ajdev33](/forum/user/59738-ajdev33 "View ajdev33's Profile")  Replied by *[ajdev33](/forum/user/59738-ajdev33 "View ajdev33's Profile")* on topic *[How to store transaction id in hikashop order table as a new field](/forum/35-orders-management/900317-how-to-store-transaction-id-in-hikashop-order-table-as-a-new-field#321564 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.3  I am working on a custom third party payment plugin. I have installed it and have implemented code to redirect on payment page and back on shop successfully. Now I want to store transaction id retrieved from payment gateway in order table as a new field.  I don't know how to store/add transaction id in order table.  I tried below code, but it is also not working.  So if anyone can help me out from this would be very helpful for me.  Thanks")*

Isn't this possible to run Alter table or new table SQL script on plugin install ? Because I want field like transaction id to be added in order table dynamically not manually.

Please suggest any solution.

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

Less More

- Posts: 86583
- Thank you received: 14324
-
-

6 years 4 months ago [\#321571](#321571) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to store transaction id in hikashop order table as a new field](/forum/35-orders-management/900317-how-to-store-transaction-id-in-hikashop-order-table-as-a-new-field#321571 "-- HikaShop version -- : 4.3.0 -- Joomla version -- : 3.9.19 -- PHP version -- : 7.3  I am working on a custom third party payment plugin. I have installed it and have implemented code to redirect on payment page and back on shop successfully. Now I want to store transaction id retrieved from payment gateway in order table as a new field.  I don't know how to store/add transaction id in order table.  I tried below code, but it is also not working.  So if anyone can help me out from this would be very helpful for me.  Thanks")*

Hi,

You can use the preflight function of Joomla plugins to do that:
[ books.google.fr/books?id=FNA3CwAAQBAJ&amp;pg...gin%20joomla&amp;f=false](https://books.google.fr/books?id=FNA3CwAAQBAJ&pg=PT51&lpg=PT51&dq=preflight+plugin+joomla&source=bl&ots=Am9U2s8pLu&sig=ACfU3U2rTDJGkP8FzdwM5XdUPcYSf19l6A&hl=en&sa=X&ved=2ahUKEwjMo9bSq6zqAhUN3BoKHd6lCH4Q6AEwBnoECAoQAQ#v=onepage&q=preflight%20plugin%20joomla&f=false)
Or what you could do is actually do a :
$orderClass-&gt;get($order_id);
To get the data already in the database, add such check: Code:

if(!isset($orderInDb-&gt;xxx)) { // run ALTER MySQL query to add the column xxx to hikashop_order }

directly before your code in the plugin

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

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