function create() { $Item = new mStoreItem(); if (isset($_POST['action'])) { $Item->__post(); if ($Item->validate() && $Item->save()) { redirect('/site-admin/store/edit/' . $Item->id()); } else { data('info_error', 'Something wen\'t wrong!'); } } else { $Item->__clearMemory(); } $this->display('store/form'); }
function addtocart($ProductID) { //Generate a new basket item $Item = new OrderItem(); $Product = new mStoreItem($ProductID); $Item->title($Product->title); $Item->source('shop:' . $Product->id()); $Item->subtitle($Product->description); $Item->quantity(1); $Item->image($Product->main_image()->filename); $Item->hidden(json_encode($Product->_data)); $Item->price($Product->price); $Item->addToOrder(); redirect('/checkout/'); }