function OpenCartToWeberpSync($ShowMessages, $db, $db_oc, $oc_tableprefix, $EmailText = '') { $begintime = time_start(); // connect to opencart DB DB_Txn_Begin($db); // check last time we run this script, so we know which records need to update from OC to webERP $LastTimeRun = CheckLastTimeRun('OpenCartToWeberp', $db); $TimeDifference = Get_SQL_to_PHP_time_difference($db); if ($ShowMessages) { prnMsg('This script was last run on: ' . $LastTimeRun . ' Server time difference: ' . $TimeDifference, 'success'); prnMsg('Server time now: ' . GetServerTimeNow($TimeDifference), 'success'); } if ($EmailText != '') { $EmailText = $EmailText . 'OpenCart to webERP Sync was last run on: ' . $LastTimeRun . "\n" . PrintTimeInformation($db); } // update order information $EmailText = SyncOrderInformation($TimeDifference, $ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // update payment information $EmailText = SyncPaypalPaymentInformation($TimeDifference, $ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // We are done! SetLastTimeRun('OpenCartToWeberp', $db); DB_Txn_Commit($db); if ($ShowMessages) { time_finish($begintime); } return $EmailText; }
function WeberpToOpenCartHourlySync($ShowMessages, $db, $db_oc, $oc_tableprefix, $ControlTx = TRUE, $EmailText = '') { $begintime = time_start(); if ($ControlTx) { DB_Txn_Begin($db); } // check last time we run this script, so we know which records need to update from OC to webERP $LastTimeRun = CheckLastTimeRun('WeberpToOpenCartHourly', $db); if ($ShowMessages) { $TimeDifference = Get_SQL_to_PHP_time_difference($db); prnMsg('This script was last run on: ' . $LastTimeRun . ' Server time difference: ' . $TimeDifference, 'success'); prnMsg('Server time now: ' . GetServerTimeNow($TimeDifference), 'success'); } if ($EmailText != '' and ControlTx) { $EmailText = $EmailText . 'webERP to OpenCart Hourly Sync was last run on: ' . $LastTimeRun . "\n" . PrintTimeInformation($db); } // update product basic information $EmailText = SyncProductBasicInformation($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // update product - sales categories relationship $EmailText = SyncProductSalesCategories($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // update product prices $EmailText = SyncProductPrices($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // update stock in hand $EmailText = SyncProductQOH($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // clean duplicated URL alias $EmailText = CleanDuplicatedUrlAlias($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText); // We are done! SetLastTimeRun('WeberpToOpenCartHourly', $db); if ($ControlTx) { DB_Txn_Commit($db); } if ($ShowMessages) { time_finish($begintime); } return $EmailText; }