Пример #1
0
 /**
  * Create a custom attribute
  * @param string $var
  * @param string $label
  * @param string $type
  */
 public static function createAttribute($var, $label, $type = "text", $section = "customers", $panel_id = null)
 {
     // Check if the attribute exists
     $attr = self::getAttributeIdByVar($var, $section);
     if (!empty($attr)) {
         return false;
     }
     $attribute = new CustomAttributes();
     $attribute['var'] = $var;
     $attribute['label'] = $label;
     $attribute['type'] = $type;
     $attribute['section'] = $section;
     $attribute['panel_id'] = $panel_id;
     return $attribute->trySave();
 }