Skip to content

Instantly share code, notes, and snippets.

@dtbaker
Last active June 2, 2018 20:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtbaker/b6cabfab3053ca36cbba989474f10088 to your computer and use it in GitHub Desktop.
Save dtbaker/b6cabfab3053ca36cbba989474f10088 to your computer and use it in GitHub Desktop.
Create a quote in UCM from a remote url
<?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