Skip to content

Instantly share code, notes, and snippets.

@midoalone
Created January 14, 2022 13:05
Show Gist options
  • Save midoalone/d0c4cb1bb45621d3a7fb7750b9032653 to your computer and use it in GitHub Desktop.
Save midoalone/d0c4cb1bb45621d3a7fb7750b9032653 to your computer and use it in GitHub Desktop.
function add_new_sales_item_post($item, $rel_id, $rel_type)
{
$custom_fields = false;
if (isset($item['custom_fields'])) {
$custom_fields = $item['custom_fields'];
}
$CI = &get_instance();
$CI->db->insert(db_prefix() . 'itemable', [
'description' => $item['description'],
'long_description' => nl2br($item['long_description']),
'qty' => $item['qty'],
'rate' => number_format($item['rate'], get_rate_decimals_place(), '.', ''),
'rel_id' => $rel_id,
'rel_type' => $rel_type,
'item_order' => $item['order'],
'unit' => $item['unit'],
]);
$id = $CI->db->insert_id();
if ($custom_fields !== false) {
handle_custom_fields_post($id, $custom_fields);
}
return $id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment