VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: tazcabe on June 27, 2014, 18:17:32 PM

Title: I can not add a new field to my table orders
Post by: tazcabe on June 27, 2014, 18:17:32 PM
Hi good afternoon, I'm trying to add a new field to the table of orders, but unfortunately not and could. That's why I come to ask for help from experts.

Start by specifying the versions I'm using:

Joomla! 2.5.13
Virtuemart 2.0.20b

The name of my table is:

dr5bo_virtuemart_orders

The field I added is called:

sucursal_id

This field already initialized in the file:
\ Administrator \ components \ com_virtuemart \ tables \ orders.php

 / ** @ Var int branch ID * /

sucursal_id $ var = 0;

In the model orders add a method which builds me a list that is constructed with the data in a table that I have in my database:

administrator \ components \ com_virtuemart \ models \ orders.php

and the code is as follows:

/*Obtiene sucursales*/

   function getSucursales() {
      $db = JFactory::getDBO();
      $query = "SELECT `id` AS `value`, `nombre_de_la_sucursal` AS text
                  FROM `#__rednovo_sucursales`";
      $db->setQuery($query);
      $options = $db->loadObjectList();
      array_unshift($options, JHTML::_('select.option',  '0', '- '. JText::_('COM_VIRTUEMART_SELECT_SUCURSAL') .' -' ));
      return $options;
   }

   /*End Obtiene sucursales*/

Finally in my view orders

administrator\components\com_virtuemart\views\orders\tmpl\orders.php

add the model

$ Mf_model = VmModel :: getModel ('orders');
$ SucursalList = $ mf_model-> getSucursales ();


and generated the list

$ Selected_option = isset ($ this-> orderslist-> sucursal_id)? $ This-> orderslist-> sucursal_id: 0;
$ This-> lists ['sucursalList'] = JHTML :: _ ('select.genericlist', $ sucursalList, 'nombre_de_la_sucursal', 'class = "inputbox"', 'value', 'text', $ selected_option, false, false);


and I add a column to the list

<!-- Se imprime el selec con el array de Sucursal -->
    <td style="position:relative;">                  
      <?php echo $this->lists['sucursalList'];?>
      <?php echo '<br>'; ?>                  
   </td>   
                        
<!--  End Sucursal -->


doing this optengo a screen like the image I attached in


How could I do, so that the branch field is updated with the value of pressing the select button to update order?



[attachment cleanup by admin]