예제 #1
0
 public function add()
 {
     include_once MODPATH . 'kfpp/models/types/MY_OptionsProduct.php';
     $id = (int) $this->uri->segment('id');
     if ($id > 0) {
         $quantity_of_product = (int) (@$_POST['quantity'] == '') ? 1 : $_POST['quantity'];
         $_SESSION['conf']['cart']['product'][$id]['quantity'] = @$_SESSION['conf']['cart']['product'][$id]['quantity'] + $quantity_of_product;
         //       if(count(@$_POST['lines']) > 0){
         //         $_SESSION['conf']['cart']['product'][$id]['lines'] = $_POST['lines'];
         //       }
         $_SESSION['conf']['cart']['product'][$id]['attr_addprices'] = 0;
         if (@$_POST['attr'] != '') {
             $xdata = null;
             $prices = 0;
             foreach ($_POST['attr'] as $key => $value) {
                 $value = (int) $value;
                 $atr = new MY_OptionsProduct();
                 $r = $atr->GetAttr($id, $value);
                 $data = null;
                 foreach ($r as $row) {
                     //             Basic::currency($row->value);
                     $data = "{$row->name_values_atributtes_product}";
                 }
                 $xdata .= "{$key} : {$data}<br/>";
                 if ($row->prefix == "+") {
                     $prices = $prices + $row->value;
                 } else {
                     $prices = $prices - $row->value;
                 }
             }
             $_SESSION['conf']['cart']['product'][$id]['attr_desc'] = $xdata;
             $_SESSION['conf']['cart']['product'][$id]['attr_addprices'] = $prices;
             //         echo $prices;
         }
         if ($this->lines) {
             $_SESSION['conf']['cart']['product'][$id]['lines'] = @$_POST['lines'];
             $_SESSION['conf']['cart']['product'][$id]['color_chocolate'] = @$_POST['color_chocolatejs'];
             $_SESSION['conf']['cart']['product'][$id]['msjpers'] = @$_POST['msjjs'];
         }
         url::redirect(url::base() . $this->__("cart") . '/');
     }
 }
예제 #2
0
 function GetAtributesByProductID($id)
 {
     include_once MODPATH . 'kfpp/models/types/MY_OptionsProduct.php';
     $atr = new MY_OptionsProduct();
     $id = (int) $id;
     $r = $atr->GetAttr($id);
     $str = null;
     $data = array();
     foreach ($r as $row) {
         $aid = $row->id_phap;
         $vals = $row->value;
         Basic::currency($vals);
         $data[$row->name_attributes_product][$aid] = "{$row->name_values_atributtes_product} ";
         //({$row->prefix} {$vals})";
     }
     foreach ($data as $nameatr => $valuesatr) {
         $nameatr2 = __($nameatr, false);
         $str .= "<b>{$nameatr2}</b> : " . form::dropdown("attr[{$nameatr}]", $valuesatr);
     }
     return $str;
 }