Documentation

Add

int
CSaleOrder::Add(
  array arFields
);

The method Add creates a new order 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:
  • LID - the ID of the site from which an order originates;
  • PERSON_TYPE_ID - payer type of the visitor who made the order (customer);
  • PAYED - specifies whether the order is paid (Y/N);
  • DATE_PAYED - the date of the order payment;
  • EMP_PAYED_ID - the ID of the user (web shop member) who has set the PAYED flag;
  • CANCELED - specifies whether the order is canceled (Y/N);
  • DATE_CANCELED - the date of the order cancellation;
  • EMP_CANCELED_ID - the ID of the user (web shop member) who has set the CANCELED flag;
  • REASON_CANCELED - text description of the order cancellation reason;
  • STATUS_ID - the order status ID;
  • EMP_STATUS_ID - the ID of the user (web shop member) who has set the current STATUS_ID;
  • PRICE_DELIVERY - cost of the order delivery;
  • ALLOW_DELIVERY - specifies whether the order can be shipped (Y/N);
  • DATE_ALLOW_DELIVERY - the date when the order was subjected for shipment;
  • EMP_ALLOW_DELIVERY_ID - the ID of the user (web shop member) who has set the current ALLOW_DELIVERY status;
  • PRICE - total order price;
  • CURRENCY - currency of the order price;
  • DISCOUNT_VALUE - total discount value;
  • USER_ID - the user ID of the customer;
  • PAY_SYSTEM_ID - pay system to handle the payment;
  • DELIVERY_ID - the ID of a delivery service that will handle the order shipment;
  • USER_DESCRIPTION - customer's order description;
  • ADDITIONAL_INFO - additional information on the order;
  • COMMENTS - auxiliary comments;
  • TAX_VALUE - total amount of tax;
  • STAT_GID - the event parameter for use in the Statistics module;
  • PS_STATUS - specifies that the order has been successfully paid (Y/N). Available only for those pay systems which can automatically notify of their orders state;
  • PS_STATUS_CODE - code of the pay system status (depends on the pay system);
  • PS_STATUS_DESCRIPTION - description of the pay system order payment result;
  • PS_STATUS_MESSAGE - message returned from the pay system;
  • PS_SUM - amount of money which was actually paid via the pay system;
  • PS_CURRENCY - payment currency;
  • PS_RESPONSE_DATE - the date when the pay system status was received.

Returned values

Returns the ID of the created order on success, or false otherwise.

Example

<?
$arFields = array(
   "LID" => "en",
   "PERSON_TYPE_ID" => 1,
   "PAYED" => "N",
   "CANCELED" => "N",
   "STATUS_ID" => "N",
   "PRICE" => 279.32,
   "CURRENCY" => "USD",
   "USER_ID" => IntVal($USER->GetID()),
   "PAY_SYSTEM_ID" => 3,
   "PRICE_DELIVERY" => 11.37,
   "DELIVERY_ID" => 2,
   "DISCOUNT_VALUE" => 1.5,
   "TAX_VALUE" => 0.0,
   "USER_DESCRIPTION" => ""
);

// add Guest ID
if (CModule::IncludeModule("statistic"))
   $arFields["STAT_GID"] = CStatistic::GetEventParam();

$ORDER_ID = CSaleOrder::Add($arFields);
$ORDER_ID = IntVal($ORDER_ID);
?>
© «Bitrix24», 2001-2024
Up