Exemplo n.º 1
0
 function getExtraFields($type = 1)
 {
     $_cats = $this->getCategories();
     $cats = array();
     foreach ($_cats as $v) {
         $cats[] = $v->category_id;
     }
     $fields = array();
     $jshopConfig = JSFactory::getConfig();
     $hide_fields = $jshopConfig->getProductHideExtraFields();
     $cart_fields = $jshopConfig->getCartDisplayExtraFields();
     $fieldvalues = JSFactory::getAllProductExtraFieldValue();
     $listfield = JSFactory::getAllProductExtraField();
     foreach ($listfield as $val) {
         if ($type == 1 && in_array($val->id, $hide_fields)) {
             continue;
         }
         if ($type == 2 && !in_array($val->id, $cart_fields)) {
             continue;
         }
         if ($val->allcats) {
             $fields[] = $val;
         } else {
             $insert = 0;
             foreach ($cats as $cat_id) {
                 if (in_array($cat_id, $val->cats)) {
                     $insert = 1;
                 }
             }
             if ($insert) {
                 $fields[] = $val;
             }
         }
     }
     $rows = array();
     foreach ($fields as $field) {
         $field_id = $field->id;
         $field_name = "extra_field_" . $field_id;
         if ($field->type == 0) {
             if ($this->{$field_name} != 0) {
                 $listid = explode(',', $this->{$field_name});
                 $tmp = array();
                 foreach ($listid as $extrafiledvalueid) {
                     $tmp[] = $fieldvalues[$extrafiledvalueid];
                 }
                 $extra_field_value = implode($jshopConfig->multi_charactiristic_separator, $tmp);
                 $rows[] = array("id" => $field_id, "name" => $listfield[$field_id]->name, "description" => $listfield[$field_id]->description, "value" => $extra_field_value, "groupname" => $listfield[$field_id]->groupname, 'field_value_ids' => $listid);
             }
         } else {
             if ($this->{$field_name} != "") {
                 $rows[] = array("id" => $field_id, "name" => $listfield[$field_id]->name, "description" => $listfield[$field_id]->description, "value" => $this->{$field_name}, "groupname" => $listfield[$field_id]->groupname);
             }
         }
     }
     $rowsblock = array();
     foreach ($rows as $k => $v) {
         if ($v['groupname'] == '') {
             $grname = 'defaultgroup';
         } else {
             $grname = $v['groupname'];
         }
         $rowsblock[$grname][] = $v;
     }
     $rows = array();
     foreach ($rowsblock as $bl => $val) {
         foreach ($val as $k => $v) {
             if ($k == 0) {
                 $v['grshow'] = 1;
             } else {
                 $v['grshow'] = 0;
             }
             if ($k == count($val) - 1) {
                 $v['grshowclose'] = 1;
             } else {
                 $v['grshowclose'] = 0;
             }
             $rows[$v['id']] = $v;
         }
     }
     return $rows;
 }
Exemplo n.º 2
0
function getProductExtraFieldForProduct($product)
{
    $fields = JSFactory::getAllProductExtraField();
    $fieldvalues = JSFactory::getAllProductExtraFieldValue();
    $displayfields = JSFactory::getDisplayListProductExtraFieldForCategory($product->category_id);
    $rows = array();
    foreach ($displayfields as $field_id) {
        $field_name = "extra_field_" . $field_id;
        if ($fields[$field_id]->type == 0) {
            if ($product->{$field_name} != 0) {
                $listid = explode(',', $product->{$field_name});
                $tmp = array();
                foreach ($listid as $extrafiledvalueid) {
                    $tmp[] = $fieldvalues[$extrafiledvalueid];
                }
                $extra_field_value = implode(", ", $tmp);
                $rows[$field_id] = array("name" => $fields[$field_id]->name, "description" => $fields[$field_id]->description, "value" => $extra_field_value);
            }
        } else {
            if ($product->{$field_name} != "") {
                $rows[$field_id] = array("name" => $fields[$field_id]->name, "description" => $fields[$field_id]->description, "value" => $product->{$field_name});
            }
        }
    }
    return $rows;
}
Exemplo n.º 3
0
 function getExtraFields($type = 1)
 {
     $_cats = $this->getCategories();
     $cats = array();
     foreach ($_cats as $v) {
         $cats[] = $v->category_id;
     }
     $fields = array();
     $jshopConfig = JSFactory::getConfig();
     $hide_fields = $jshopConfig->getProductHideExtraFields();
     $cart_fields = $jshopConfig->getCartDisplayExtraFields();
     $fieldvalues = JSFactory::getAllProductExtraFieldValue();
     $listfield = JSFactory::getAllProductExtraField();
     foreach ($listfield as $val) {
         if ($type == 1 && in_array($val->id, $hide_fields)) {
             continue;
         }
         if ($type == 2 && !in_array($val->id, $cart_fields)) {
             continue;
         }
         if ($val->allcats) {
             $fields[] = $val;
         } else {
             $insert = 0;
             foreach ($cats as $cat_id) {
                 if (in_array($cat_id, $val->cats)) {
                     $insert = 1;
                 }
             }
             if ($insert) {
                 $fields[] = $val;
             }
         }
     }
     $rows = array();
     foreach ($fields as $field) {
         $field_id = $field->id;
         $field_name = "extra_field_" . $field_id;
         if ($field->type == 0) {
             if ($this->{$field_name} != 0) {
                 $listid = explode(',', $this->{$field_name});
                 $tmp = array();
                 foreach ($listid as $extrafiledvalueid) {
                     $tmp[] = $fieldvalues[$extrafiledvalueid];
                 }
                 $extra_field_value = implode(", ", $tmp);
                 $rows[] = array("id" => $field_id, "name" => $listfield[$field_id]->name, "description" => $listfield[$field_id]->description, "value" => $extra_field_value, "groupname" => $listfield[$field_id]->groupname);
             }
         } else {
             if ($this->{$field_name} != "") {
                 $rows[] = array("id" => $field_id, "name" => $listfield[$field_id]->name, "description" => $listfield[$field_id]->description, "value" => $this->{$field_name}, "groupname" => $listfield[$field_id]->groupname);
             }
         }
     }
     return $rows;
 }