Documentation

Add

int
CSaleDelivery::Add(
  array arFields
);

The method Add adds a new delivery service.

Parameters

ParameterDescription
arFields Associated array containing the delivery service parameters. In this array, the keys are the parameter names, and the values are the delivery parameter values. The following keys are possible:
  • NAME - name of the delivery service (required; specified in the language of the site to which this delivery service is bound);
  • LID - the site to which this delivery service is bound;
  • PERIOD_FROM - minimum time of delivery;
  • PERIOD_TO - maximum time of delivery;
  • PERIOD_TYPE - time of delivery measurement unit: H - hours, D - days, M - months;
  • WEIGHT_FROM - minimum order weight that this delivery service can handle (measurement unit must be common within the site);
  • WEIGHT_TO - maximum order weight that this delivery service can handle (measurement unit must be common within the site);
  • ORDER_PRICE_FROM - minimum order price that this delivery service can handle;
  • ORDER_PRICE_TO - maximum order price that this delivery service can handle;
  • ORDER_CURRENCY - currency in which both ORDER_PRICE_FROM and ORDER_PRICE_TO are specified;
  • ACTIVE - delivery service active state flag (Y/N);
  • PRICE - cost of delivery;
  • CURRENCY - currency of the cost;
  • SORT - sort weight;
  • DESCRIPTION - delivery service description;
  • LOCATIONS - array of arrays in the format:
    array("LOCATION_ID"=>"location_ID or location_group_ID",
          "LOCATION_TYPE"=>"L - location or G - group")
    This array defines locations and group of locations allowed by this delivery service.

Returned values

Returns the new record ID on success or false otherwise.

Example


<?
$arFields = array(
   "NAME" => "By courier",
   "LID" => "en",
   "PERIOD_FROM" => 1,
   "PERIOD_TO" => 3,
   "PERIOD_TYPE" => "D",
   "WEIGHT_FROM" => 0,
   "WEIGHT_TO" => 2500,
   "ORDER_PRICE_FROM" => 0,
   "ORDER_PRICE_TO" => 10000,
   "ORDER_CURRENCY" => "EUR",
   "ACTIVE" => "Y",
   "PRICE" => 58,
   "CURRENCY" => "RUR",
   "SORT" => 100,
   "DESCRIPTION" => "Delivers within 3 to 10 business days".
                    "after the order acceptance.",
   "LOCATIONS" => array(
      array("LOCATION_ID"=>1, "LOCATION_TYPE"=>"L"),
      array("LOCATION_ID"=>3, "LOCATION_TYPE"=>"G")
      )
);

$ID = CSaleDelivery::Add($arFields);
if ($ID<=0)
   echo "Error adding a delivery service";
?>
© «Bitrix24», 2001-2024
Up