Documentation

GetList

CDBResult
CSaleOrderProps::GetList(
  string &by,
  string &order,
  array arFilter = Array()
);

The method GetList returns an optionally sorted and filtered list of order properties.

Parameters

ParameterDescription
by Specifies the name of a parameter by which the sorting is to be performed. 

The following values are possible:
  • SORT - sort weight (default);
  • NAME - the property name;
  • ID - the property ID;
  • PERSON_TYPE_ID - payer type;
  • TYPE - property type;
  • REQUIED - specifies the field is required (Y/N);
  • USER_PROPS - specifies the property is included in the customer profile (Y/N);
  • CODE - mnemonic property code;
  • PROPS_GROUP_ID - the property group ID.
order Sort order. Can be one of the following:
  • ASC - ascending;
  • DESC - descending.
arFilter The filter is an associated array whose keys are the discount parameter names, and values are the conditions.

The following keys are possible:
  • PERSON_TYPE_ID - payer type;
  • ID - the property ID;
  • TYPE - property type;
  • CODE - mnemonic property code;
  • REQUIED - specifies the field is required (Y/N);
  • USER_PROPS - specifies the property is included in the customer profile (Y/N);
  • IS_LOCATION - specifies the field value is to be used as a customer location when calculating the delivery price (only for LOCATION fields) (Y/N);
  • IS_LOCATION4TAX - specifies the use of the property value as a customer location for the tax calculations (only for LOCATION fields) (Y/N);
  • IS_PAYER - denotes the field value should be used as a payer name (Y/N);
  • IS_EMAIL - denotes the field value should be used as a customer's e-mail address (Y/N);
  • IS_PROFILE_NAME - denotes the field value should be used as a customer's profile name (Y/N);
  • PROPS_GROUP_ID - the property group ID.

Return Values

Returns an instance of CDBResult, containing a set of associated arrays with the following keys.

Key Description
ID The property ID.
PERSON_TYPE_ID Payer type.
NAME The property name.
TYPE Property type:
  • CHECKBOX - check box button;
  • TEXT - single line text;
  • SELECT - drop-down list;
  • MULTISELECT - multiple selection list;
  • TEXTAREA - multiple line text field;
  • LOCATION - location;
  • RADIO - radio button;
REQUIED Specifies the field is required (Y/N).
DEFAULT_VALUE Default value.
SORT Sort weight.
USER_PROPS Specifies the field is included in the customer profile (Y/N)
IS_LOCATION Specifies the field value is to be used as a customer location when calculating the delivery price (only for LOCATION fields) (Y/N).
PROPS_GROUP_ID The property group ID.
SIZE1 Field width.
SIZE2 Field height.
DESCRIPTION Property description.
IS_EMAIL Denotes the field value should be used as a customer's e-mail address (Y/N).
IS_PROFILE_NAME Denotes the field value should be used as a customer's profile name (Y/N).
IS_PAYER Denotes the field value should be used as a payer name (Y/N).
IS_LOCATION4TAX Specifies the use of the property value as a customer location for the tax calculations (only for LOCATION fields) (Y/N).
CODE Property mnemonic code.

Example


<?
// Display a form for inputting the order properties for prop. group with ID==5
// included in the profile
// for payer type with ID==2
$db_props = CSaleOrderProps::GetList(($by="SORT"), 
                                     ($order="ASC"),
                                     Array("PERSON_TYPE_ID"=>2,
                                           "PROPS_GROUP_ID"=>5,
                                           "USER_PROPS"=>"Y"));
if ($props = $db_props->Fetch())
{
    echo "Specify the order parameters:<br>";
    do
    {
        echo $props["NAME"];
        if ($props["REQUIED"]=="Y" || 
            $props["IS_EMAIL"]=="Y" || 
            $props["IS_PROFILE_NAME"]=="Y" || 
            $props["IS_LOCATION"]=="Y" || 
            $props["IS_LOCATION4TAX"]=="Y" || 
            $props["IS_PAYER"]=="Y")
        {
            echo "*";
        }
        echo ": ";

        if ($props["TYPE"]=="CHECKBOX")
        {
            echo '<input type="checkbox" 
                   class="inputcheckbox" 
                   name="ORDER_PROP_'.$props["ID"].'" 
                   value="Y"'.(($props["DEFAULT_VALUE"]=="Y")?" 
                   checked":"").'>';
        }
        elseif ($props["TYPE"]=="TEXT")
        {
            echo '<input type="text" 
                   class="inputtext" 
                   size="'.((IntVal($props["SIZE1"])>0)?$props["SIZE1"]:30).'" 
                   maxlength="250" 
                   value="'.htmlspecialchars($props["DEFAULT_VALUE"]).'" 
                   name="ORDER_PROP_'.$props["ID"].'">";
        }
        elseif ($props["TYPE"]=="SELECT")
        {
            echo '<select 
                   name="ORDER_PROP_'.$props["ID"].'" 
                   size="'.((IntVal($props["SIZE1"])>0)?$props["SIZE1"]:1).'">';
            $db_vars = CSaleOrderPropsVariant::GetList(($by="SORT"), 
                                                       ($order="ASC"), 
                                                       Array("ORDER_PROPS_ID" =>
                                                                   $props["ID"]));
            while ($vars = $db_vars->Fetch())
            {
                echo '<option 
                       value="'.$vars["VALUE"].'"'.
                       (($vars["VALUE"]==$props["DEFAULT_VALUE"])?" selected":"").
                       '>'.htmlspecialchars($vars["NAME"]).'</option>';
            }
            echo '</select>';
        }
        elseif ($props["TYPE"]=="MULTISELECT")
        {
            echo '<select 
                   multiple 
                   name="ORDER_PROP_'.
                   $props["ID"].'[]" size="'.
                   ((IntVal($props["SIZE1"])>0)?$props["SIZE1"]:5).'">';
            $arDefVal = Split(",", $props["DEFAULT_VALUE"]);
            for ($i = 0; $i<count($arDefVal); $i++)
                $arDefVal[$i] = Trim($arDefVal[$i]);

            $db_vars = CSaleOrderPropsVariant::GetList(($by="SORT"), 
                                                       ($order="ASC"), 
                                                       Array("ORDER_PROPS_ID" => 
                                                                    $props["ID"]));
            while ($vars = $db_vars->Fetch())
            {
                echo '<option 
                       value="'.$vars["VALUE"].'"'.
                       (in_array($vars["VALUE"], $arDefVal)?" selected":"").'>'.
                       htmlspecialchars($vars["NAME"]).'</option>';
            }
            echo '</select>';
        }
        elseif ($props["TYPE"]=="TEXTAREA")
        {
            echo '<textarea rows="'.
                   ((IntVal($props["SIZE2"])>0)?$props["SIZE2"]:4).
                   '" cols="'.((IntVal($props["SIZE1"])>0)?$props["SIZE1"]:40).
                   '" name="ORDER_PROP_'.$props["ID"].'">'.
                   htmlspecialchars($props["DEFAULT_VALUE"]).'</textarea>';
        }
        elseif ($props["TYPE"]=="LOCATION")
        {
            echo '<select 
                   name="ORDER_PROP_'.$props["ID"].
                   '" size="'.((IntVal($props["SIZE1"])>0)?$props["SIZE1"]:1).'">';
            $db_vars = CSaleLocation::GetList(Array("SORT"=>"ASC", 
                                                    "COUNTRY_NAME_LANG"=>"ASC", 
                                                    "CITY_NAME_LANG"=>"ASC"), 
                                                    array(), LANGUAGE_ID);
            while ($vars = $db_vars->Fetch())
            {
                echo '<option 
                       value="'.$vars["ID"].'"".
                       ((IntVal($vars["ID"])==IntVal($props["DEFAULT_VALUE"]))?" selected":"").
                       '>'.htmlspecialchars($vars["COUNTRY_NAME"].
                       " - ".$vars["CITY_NAME"]).'</option>';
            }
            echo '</select>';
        }
        elseif ($props["TYPE"]=="RADIO")
        {
            $db_vars = CSaleOrderPropsVariant::GetList(($by="SORT"), 
                                                       ($order="ASC"), 
                                                       Array("ORDER_PROPS_ID"=>
                                                                    $props["ID"]));
            while ($vars = $db_vars->Fetch())
            {
                echo '<input 
                       type="radio" 
                       name="ORDER_PROP_'.$props["ID"].'" value="'.
                       $vars["VALUE"].'"'.
                       (($vars["VALUE"]==$props["DEFAULT_VALUE"])?" checked":"").
                       '>'.htmlspecialchars($vars["NAME"]).'<br>';
            }
        }

        if (strlen($props["DESCRIPTION"])>0)
        {
            echo "<br><small>".$props["DESCRIPTION"]."</small>";
        }

        echo "<br>";
    }
    while ($props = $db_props->Fetch());
}
?>
© «Bitrix24», 2001-2024
Up