- Posts: 45
- Thank you received: 0
How to save order details in a plugin
- paulvanharen
-
Topic Author
- Offline
Less
More
11 years 8 months ago - 11 years 8 months ago #187787
by paulvanharen
How to save order details in a plugin was created by paulvanharen
-- 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:
Your help is appreciated.
Best regards, Paul
-- 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:
- Add the transaction ID to $order->order_payment_params. Nothing is saved.
- Add the transaction ID, and call $order->save($order). White screen, function not found apparently.
- 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.
- 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.
Your help is appreciated.
Best regards, Paul
Last edit: 11 years 8 months ago by paulvanharen.
Please Log in or Create an account to join the conversation.
11 years 8 months ago #187800
by Xavier
Replied by Xavier on topic How to save order details in a plugin
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->CUSTOMFIELD_NAME and save the order.
To use the "save" function you need to call the order class before:
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->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->CUSTOMFIELD_NAME)){
$order->CUSTOMFIELD_NAME = $transaction_id;
}
$orderClass->save($order);
Please Log in or Create an account to join the conversation.
- paulvanharen
-
Topic Author
- Offline
Less
More
- Posts: 45
- Thank you received: 0
11 years 8 months ago - 11 years 8 months ago #187930
by paulvanharen
Replied by paulvanharen on topic How to save order details in a plugin
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
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.
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->save($order);
Last edit: 11 years 8 months ago by paulvanharen.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
11 years 8 months ago #187977
by Mohamed Thelji
Replied by Mohamed Thelji on topic How to save order details in a plugin
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->history->history_data".
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->history->history_data".
Please Log in or Create an account to join the conversation.
Time to create page: 0.276 seconds