Answer the question
In order to leave comments, you need to log in
How to get marked extras. delivery services in the order?
When sending a mail template, you need to add to the letter the extras marked when placing an order. delivery services. Didn't find how to do it?
Answer the question
In order to leave comments, you need to log in
It was not possible to do this in a simple way. There is no description of \Bitrix\Sale\Delivery\ExtraServices at all, I do
n’t know how correct this solution is, but I somehow implemented it:
$order = \Bitrix\Sale\Order::load($arOrder['ID']);
$shipmentCollection = $order->getShipmentCollection();
$stores = \Bitrix\Sale\Delivery\ExtraServices\Manager::getExtraServicesList($arOrder['DELIVERY_ID']);
foreach ($shipmentCollection as $shipment){
$extra = $shipment->getExtraServices(); //массив значений доп.услуги, типа array([10]=>'Y')
if(!empty($extra)){
foreach($extra as $key => $value){
if($value == 'Y')
echo $stores[$key]['NAME']; // получаем наименование доп. услуги
}
}
}
another version of the crutch
if (!\Bitrix\Main\Loader::IncludeModule('iblock'))
die();
if (!\Bitrix\Main\Loader::IncludeModule('sale'))
die();
if (!\Bitrix\Main\Loader::IncludeModule('catalog'))
die();
global $APPLICATION, $USER;
//объект заказа
$order = \Bitrix\Sale\Order::load($orderID);
//скидки
$discountData = $order->getDiscount()->getApplyResult(); //скидки
$discount = $discountData['PRICES']['BASKET'];
//корзина
$basket = $order->getBasket();
$arBasket = $basket->getListOfFormatText();
foreach( $arBasket as $kBastetItem=>$vBastetItem)
{
$tmp = $discount[$kBastetItem];
if(isset($tmp['DISCOUNT']) && (int)$tmp['DISCOUNT'] > 0)
$arBasket[$kBastetItem] .= '(скидка '.SaleFormatCurrency($tmp['DISCOUNT'], "RUB") . ')';
}
//доставка
$dilevery = array('Служба доставки: ');
//отгрузки
$shipmentCollection = $order->getShipmentCollection();
foreach($shipmentCollection as $shipment) {
$shipment_id = $shipment->getId();
if ($shipment->isSystem())
continue;
$dilevery[0] .= $shipment->getField("DELIVERY_NAME");
$dileveryId = $shipment->getField("DELIVERY_ID");
$dileveryPrice = $order->getDeliveryPrice();
if((float)$dileveryPrice > 0)
$dilevery[0] .= ' ('.SaleFormatCurrency($dileveryPrice , "RUB") . ')';
$ExtraServices = \Bitrix\Sale\Delivery\ExtraServices\Manager::getExtraServicesList($dileveryId);
if(!empty($ExtraServices)){
$shipmentExtraServices = \Bitrix\Sale\Delivery\ExtraServices\Manager::getValuesForShipment($shipment_id,$dileveryId);
foreach($ExtraServices as $k => $v) {
$dilevery[1] = $v["PARAMS"]["PRICES"][$shipmentExtraServices[$k]]['TITLE'];
}
}
}
//св-ва заказа
$arProp = array();
$propertyCollection = $order->getPropertyCollection();
foreach ($propertyCollection as $k => $property)
{
$v = $property ->getValue();
if(!empty($v)){
$tmp = $property -> getProperty();
if( $tmp['CODE'] == 'KURERDOSTAVKA')
continue;
if($tmp['CODE'] == 'PUNCKTVIDACHI'){
$dilevery[1] = $tmp['NAME'].': '.$dilevery[1];
}
else
{
$arProp[$tmp['NAME']] = $v;
}
}
}
//Платежная система
$paymentCollection = $order->getPaymentCollection();
foreach ($paymentCollection as $payment) {
$psID = $payment->getPaymentSystemId(); // ID платежной системы
$psName = $payment->getPaymentSystemName();
}
//массив результатов
$arResult = array_values($arBasket);
$arResult[] = '';
$arResult = array_merge($arResult,$dilevery);
$arResult[] = 'Способ оплаты: '. ($psID == 11 ? "Оплата картой" : $psName);
$arResult[] = '';
foreach($arProp as $k=>$v)
{
$arResult[] = $k.': '.$v;
}
//комментарий к заказу
$USER_DESCRIPTION = $order->getField("USER_DESCRIPTION");
if(!empty( $USER_DESCRIPTION )){
$arResult[] = '';
$arResult[] = 'Комментарий к заказу:';
$arResult[] = $USER_DESCRIPTION;
}
//$arResult[] = '';
//$arResult[] = 'Сумма заказа: '.SaleFormatCurrency($order->getField('PRICE') , "RUB");
$arFields['ORDER_LIST'] = implode("<br>", $arResult);
This is how I displayed additional services in the last step sale.order.ajax - confirm.php
$order = \Bitrix\Sale\Order::load($arResult['ORDER']['ID']);
$shipmentCollection = $order->getShipmentCollection();
foreach ($shipmentCollection as $shipment)
{
if ($shipment->isSystem())
continue;
$shipment_id = $shipment->getId();
$dileveryId = $shipment->getField("DELIVERY_ID");
$extraValues = $shipment->getExtraServices();
$extraServicesManager = new \Bitrix\Sale\Delivery\ExtraServices\Manager($dileveryId, "", $extraValues);
$extraServices = $extraServicesManager->getItems();
foreach($extraServices as $extra)
{
$cost = $extra->getCost();
$name = $extra->getName();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question