Last active
June 2, 2018 20:23
-
-
Save dtbaker/b6cabfab3053ca36cbba989474f10088 to your computer and use it in GitHub Desktop.
Create a quote in UCM from a remote url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
chdir('/path/to/ucm/folder/on/webhost/'); | |
include('init.php'); // the UCM init code. | |
// login as admin | |
module_security::user_id_temp_set(1); | |
$customer_data = array( | |
'customer_name' => 'Name Here', | |
// other customer database fields here. see ucm_customer database table. | |
); | |
$customer_id = $plugins['customer']->save_customer(false, $customer_data); | |
echo "Created customer with ID: $customer_id "; | |
$quote_data = array( | |
'customer_id' => $customer_id, | |
'name' => 'Test Quote', | |
// other quote fields here. see ucm_quote database table. | |
); | |
$save_status = $plugins['quote']->save_quote( false, $quote_data ); | |
$quote_id = !empty( $save_status['quote_id'] ) ? $save_status['quote_id'] : false; | |
if( $quote_id ){ | |
$new_task_data = array('quote_task' => array()); | |
$new_task_data['quote_task'][] = array( | |
'description' => 'something', | |
'hours' => 1, | |
'amount' => 123, | |
); | |
$new_task_data['quote_task'][] = array( | |
'description' => 'something', | |
'hours' => 1, | |
'amount' => 123, | |
); | |
$plugins['quote']->->save_quote_tasks($quote_id, $new_task_data); | |
}else{ | |
echo "Failed to create quote"; | |
} | |
// restore logged out state. | |
module_security::user_id_temp_restore(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment