I have a frontend shopping cart over a fuelCMS website, which saves the cart data serialized in a "cart" field inside a "orders" table.
Based on this:
http://docs.getfuelcms.com/general/models#serialized How does it supposes that "cart" field will be displayed in the CMS inside the "orders" model?
Thanks!
Comments
http://docs.getfuelcms.com/general/forms#template
Here is my code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once(FUEL_PATH.'models/Base_module_model.php');
class Orders_model extends Base_module_model {
public $required = array('nombre',"apellido","empresa","email");
public $serialized_fields = array('cart');
function __construct()
{
parent::__construct('orders');
}
function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE)
{
$this->db->select('id, nombre, apellido, email, date_added', FALSE);
$data = parent::list_items($limit, $offset, $col, $order, $just_count);
// check just_count is FALSE or else $data may not be a valid array
if (empty($just_count))
{
foreach($data as $key => $val)
{
$data[$key]['nombre'] = htmlentities($val['nombre'], ENT_QUOTES, 'UTF-8');
}
}
return $data;
}
function form_fields($values = array(), $related = array())
{
$fields = parent::form_fields($values, $related);
// ******************* ADD CUSTOM FORM STUFF HERE *******************
$fields["cart"] = array('display_label' => TRUE,
'add_extra' => FALSE,
'init_display' => 'none',
'dblclick' => 'accordion',
'repeatable' => TRUE,
'style' => 'width: 900px;',
'type' => 'template',
'label' => 'detalles del carrito',
'title_field' => 'name',
'fields' => array(
'Item' => array('type' => 'section', 'label' => '{__name__}'),
'qty' => array('style' => 'width: 800px'),
'name' => array("type"=>"text"),
'price' => array('type' => 'textarea', 'style' => 'width: 800px; height: 500px;'),
)
);
return $fields;
}
Thanks!
When the user submits his cart, that data is inserted in an "orders" table.
Thanks!
'add_extra' => FALSE,
'dblclick' => 'accordion',
'repeatable' => TRUE,
'style' => 'width: 900px;',
'type' => 'template',
'label' => 'detalles del carrito',
'title_field' => 'name',
'fields' => array(
'Item' => array('type' => 'section', 'label' => '{__name__}'),
'qty' => array('style' => 'width: 800px'),
'name' => array("type"=>"text"),
'price' => array('type' => 'textarea', 'style' => 'width: 800px; height: 500px;'),
)
);