Hello everyone,
I need to save customer/order data to a remote database tables when a new customer registers or when a new order is placed.
Any idea where to start?
Thank you
Hello everyone,
I need to save customer/order data to a remote database tables when a new customer registers or when a new order is placed.
Any idea where to start?
Thank you
Hi
Just export the required info.
Barry
If you need this in real-time, then you will have to hook into each of those events and then send the data in the expected format to the destination. It is custom work based on what info you want to send and how you want to send it.
Thanks for the response tbirnseth. Just wondering where to find a list of available cs-cart hooks!!
Check hooks in the following functions:
- fn_update_user (app/functions/fn.users.php)
- fn_place_order (app/functions/fn.cart.php)
Thank you very much, that was very helpful.
We are glad to help you
Sorry but I need help again.
I created the following plugin, a test one just to see if it works but it doesn't seem to be working. I tried to register as a new customer few times after installing and activating this addon but nothing was saved in the database table.
init.php
if ( !defined(‘AREA’) ) { die(‘Access denied’); }fn_register_hooks(
‘fn_update_user_pre’
);?>
func.php
if ( !defined(‘AREA’) ) { die(‘Access denied’); }function fn_export_customer_to_erp_update_user_pre($user_id, $user_data, &$auth, $ship_to_another, $notify_user){
// Some test to make sure addon is being called. Tables is already created
$name = rand(90,9999);
db_query(‘INSERT INTO export_customer_to_erp_addon_data(name) VALUES ($name)’);
}?>
addon.xml
export_customer_to_erp 1.0 Export Customers to ERP Export customers from CS-Cart to client ERP system 100500
Thanks
Try to change
db_query(‘INSERT INTO export_customer_to_erp_addon_data(name) VALUES ($name)’);to
db_query(“INSERT INTO export_customer_to_erp_addon_data(name) VALUES (‘$name’)”);The VALUE $name must be in single quotes. You might be able to see the error in your Logs if you have DB error loggin enabled.
$db_data = array(‘name’ => $name);Which will do the appropriate quoting for you. Field is the index of the array and the VALUE is the value.
db_query(“INSERT INTO export_customer_to_erp_addon_data ?e”, $db_data);
in your addon.xml. Otherwise it will be installed as disabled.
active
Hi tbirnseth,
I followed all the instructions but nothing happened. Seems like the addon is never been called!
Did you confirm that it is listed as Active?
Otherwise, all else appears correct.
Yes I did, that's odd.
Please use
fn_register_hooks( 'update_user_pre' );
instead of
fn_register_hooks( 'fn_update_user_pre' );
Perfect. Thanks eComLabs. That worked :)
But just wondering why there isn't a update_user_post function!
I was hoping to be able to get the user data after he registers!
Sorry forget my previous message. I managed to get the user data for new registrations by using.
if(empty($user_id)){ // code here }
Thanks again
There is the update_profile hook at the end of this function:
You can also use it
Perfect. Thanks a lot
You are welcome! :)
Okay guys back to this question, how do I get the newly inserted user ID in the "update_user_pre" function??