D
D
dimas75252020-05-11 17:27:10
1C-Bitrix
dimas7525, 2020-05-11 17:27:10

How to calculate the price in the delivery processor based on the properties of the order?

I write my delivery handler based on the code:

CModule::IncludeModule("sale");

AddEventHandler("sale", "onSaleDeliveryHandlersBuildList", array('CFTeaCourier', 'Init'));

class CFTeaCourier
{
  function Init()
  {
    return array(
      /* Основное описание */
      "SID" => "courier",
      "NAME" => "Доставка курьером",
      "DESCRIPTION" => "Доставка в течении дня",
      "DESCRIPTION_INNER" => "Доставка в течении дня",
      "BASE_CURRENCY" => COption::GetOptionString("sale", "default_currency", "RUB"),
      "HANDLER" => __FILE__,

      /* Методы обработчика */
      "DBGETSETTINGS" => array("CFTeaCourier", "GetSettings"),
      "DBSETSETTINGS" => array("CFTeaCourier", "SetSettings"),
      "GETCONFIG" => array("CFTeaCourier", "GetConfig"),
      "COMPABILITY" => array("CFTeaCourier", "Compability"),
      "CALCULATOR" => array("CFTeaCourier", "Calculate"),

      /* Список профилей доставки */
      "PROFILES" => array(
        "courier" => array(
          "TITLE" => "По городу",
          "DESCRIPTION" => "Доставка в течении дня",
          "RESTRICTIONS_WEIGHT" => array(0), // без ограничений
          "RESTRICTIONS_SUM" => array(0), // без ограничений
        ),
      )
    );
  }

  /**
   * настройки обработчика
   */
  function GetConfig()
  {
    $arConfig = array(
      "CONFIG_GROUPS" => array(),
      "CONFIG" => array(),
    );

    return $arConfig;
  }

  /**
   * подготовка настроек для занесения в базу данных
   */
  function SetSettings($arSettings)
  {
    foreach ($arSettings as $key => $value) {
      if (strlen($value) > 0) {
        $arSettings[$key] = doubleval($value);
      } else {
        unset($arSettings[$key]);
      }
    }

    return serialize($arSettings);
  }

  /**
   * подготовка настроек, полученных из базы данных
   */
  function GetSettings($strSettings)
  {
    return unserialize($strSettings);
  }

  /**
   * метод проверки совместимости
   */
  function Compability($arOrder, $arConfig)
  {
    return array('courier');
  }

  /**
   * собственно, рассчет стоимости
   */
  function Calculate($profile, $arConfig, $arOrder, $STEP, $TEMP = false)
  {
    return array(
      "RESULT" => "OK",
      "VALUE" => 100
    );
  }
}


Is it possible to calculate the price in the Calculate function based on the property of the order, which the user selects already at the stage of placing an order?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question