Ejemplo n.º 1
0
 /**
  * Generates a selectlist for the specified Product Attribute 
  *
  * @param unknown_type $productattribute_id 
  * @param unknown_type $selected
  * @param unknown_type $name
  * @param unknown_type $attribs
  * @param unknown_type $idtag
  * @return unknown_type
  */
 public static function productattributeoptions($productattribute_id, $selected, $name = 'filter_pao', $attribs = array('class' => 'inputbox'), $idtag = null, $opt_selected = array(), $user_id = 0)
 {
     $uid = $user_id == 0 ? JFactory::getUser()->id : $user_id;
     $list = array();
     $pid = !empty($attribs['pid']) ? $attribs['pid'] : null;
     $changed_attr = !empty($attribs['changed_attr']) ? $attribs['changed_attr'] : -1;
     $changed_pao = !empty($attribs['changed_pao']) ? $attribs['changed_pao'] : -1;
     if (empty($pid)) {
         $items = array();
     } else {
         $items = TiendaHelperProduct::getAvailableAttributeOptions($pid, $productattribute_id, $changed_attr, $changed_pao, $opt_selected);
     }
     $geozones = array();
     $shipping = false;
     if (count($items)) {
         $shipping = $items[0]->product_ships;
         if ($shipping) {
             Tienda::load('TiendaHelperProduct', 'helpers.product');
             Tienda::load('TiendaHelperUser', 'helpers.user');
             $geozones = TiendaHelperUser::getGeoZones($uid);
             if (empty($geozones)) {
                 // use the default
                 $table = JTable::getInstance('Geozones', 'TiendaTable');
                 $table->load(array('geozone_id' => Tienda::getInstance()->get('default_tax_geozone')));
                 $geozones = array($table);
             }
         }
     }
     foreach (@$items as $item) {
         if ($shipping) {
             $tax = TiendaHelperProduct::getTaxTotal($item->product_id, $geozones, $item->productattributeoption_price);
             $item->productattributeoption_price += $tax->tax_total;
         }
         // Do not display the prefix if it is "=" (it's not good to see =�13, better �13)
         if ($item->productattributeoption_prefix != '=') {
             $display_suffix = $item->productattributeoption_price > '0' ? ": " . $item->productattributeoption_prefix . TiendaHelperBase::currency($item->productattributeoption_price) : '';
         } else {
             $display_suffix = $item->productattributeoption_price > '0' ? ": " . TiendaHelperBase::currency($item->productattributeoption_price) : '';
         }
         $display_name = JText::_($item->productattributeoption_name) . $display_suffix;
         if ($item->is_blank) {
             $list[] = self::option(0, $display_name);
         } else {
             $list[] = self::option($item->productattributeoption_id, $display_name);
         }
     }
     return self::genericlist($list, $name, $attribs, 'value', 'text', $selected, $idtag);
 }