Bitrix Site Manager

CSaleOrderProps::Add

int
CSaleOrderProps::Add(
  array arFields
);

The method Add creates a new order property based on the supplied parameters.

Parameters

ParameterDescription
arFields Associated array of an order parameters whose keys are the order parameter names, and values are the parameter values. The following values are possible:
  • PERSON_TYPE_ID - the payer type ID;
  • NAME - the property name (the payer type is dependent on a site while the latter depends on the language used. This implies that the property name should be specified in the corresponding language);
  • 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 - the 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 - field 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.

Return Values

The ID of the added order property.

Example



<?
$arFields = array(
    "PERSON_TYPE_ID" => 2,
    "NAME" => "Includes",
    "TYPE" => "RADIO",
    "REQUIED" => "Y",
    "DEFAULT_VALUE" => "F",
    "SORT" => 100,
    "CODE" => "COMPLECT",
    "USER_PROPS" => "N",
    "IS_LOCATION" => "N",
    "IS_LOCATION4TAX" => "N",
    "PROPS_GROUP_ID" => 1,
    "SIZE1" => 0,
    "SIZE2" => 0,
    "DESCRIPTION" => "",
    "IS_EMAIL" => "N",
    "IS_PROFILE_NAME" => "N",
    "IS_PAYER" => "N"
);

// If the property ID is set, change the property, otherwise add a new one
if ($ID>0)
{
    if (!CSaleOrderProps::Update($ID, $arFields))
    {
        echo "Error modifying property";
    }
    else
    {
        // Update the property value mnemonic code (redundant data for speed-up)
        $db_order_props_tmp = CSaleOrderPropsValue::GetList(($b="NAME"),
                                                            ($o="ASC"),
                                                            Array("ORDER_PROPS_ID"=>$ID));
        while ($ar_order_props_tmp = $db_order_props_tmp->Fetch())
        {
            CSaleOrderPropsValue::Update($ar_order_props_tmp["ID"], 
                                         array("CODE" => "COMPLECT"));
        }
    }
}
else
{
    $ID = CSaleOrderProps::Add($arFields);
    if ($ID<=0)
        echo "Error adding property";
}
?>