private function prepareItem($item)
{
// if only the product key is set we'll load the cost and notes
if (!empty($item['product_key']) && empty($item['cost']) && empty($item['notes'])) {
$product = Product::findProductByKey($item['product_key']);
if ($product) {
if (empty($item['cost'])) {
$item['cost'] = $product->cost;
}
if (empty($item['notes'])) {
$item['notes'] = $product->notes;
}
}
}
$fields = ['cost' => 0, 'product_key' => '', 'notes' => '', 'qty' => 1];
foreach ($fields as $key => $val) {
if (!isset($item[$key])) {
$item[$key] = $val;
}
}
return $item;
}