Answer the question
In order to leave comments, you need to log in
How to add product properties to a letter to a customer when ordering?
There are properties on the product card, these properties fly with the product to the basket, then order ...
The network is full of examples of how to add order fields, delivery type or address to emails ...
But how to add product properties is not clear, for example: Men's shirt (size XXL), only the name flies to the letter, without the size.
The only example that I found on Habré did not work, or I did not use it correctly, because it is not clear: https://habr.com/sandbox/70044/
He writes
Since CSaleBasket::GetList does not return properties, I had to use CIBlockElement::GetById.
$rsElem = CIBlockElement::GetById($arItem["PRODUCT_ID"]);
$arElem = $rsElem->GetNextElement();
$arProps = $arElem->GetProperties();
// Письмо пользователю при оформлении нового заказа
AddEventHandler("sale", "OnOrderAdd", Array("mail_new", "OnOrderAdd_mail"));
class mail_new
{
function OnOrderAdd_mail($ID, $val)
{
// Получаем имя и мэйл пользователя
$rsUser = CUser::GetByID($val["USER_ID"]);
$arUser = $rsUser->Fetch();
$arUser_name = $arUser["LAST_NAME"]." ".$arUser["NAME"];
$arUser = $arUser["EMAIL"];
// Получаем Содержимое заказа
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"DELAY" => "N",
"CAN_BUY" => "Y",
"ORDER_ID" => "NULL"
),
false,
false,
array()
);
$tim = date("d.m.Y");
$zak = "Корзина заказа:<br /><table border='1'>";
$zak = $zak."<tr><td align='center'>Товар</td><td align='center'>Цена</td><td align='center'>Кол-во</td><td align='center'>Сумма</td></tr>";
while ($arItem = $dbBasketItems->Fetch())
{$number = $arItem["PRICE"];
$num = number_format($number,0,'.','');
$st = (int)$arItem["QUANTITY"]*$arItem["PRICE"];
$kol_vo = (int)$arItem["QUANTITY"];
$zak = $zak."<tr><td align='left'>"."<a href='".$arItem["DETAIL_PAGE_URL"]."'>".$arItem["NAME"]."</a></td><td align='left'>".$num."</td><td align='left'>".$kol_vo."</td><td align='left'>".$st."</td></tr>";
}
$arDeliv = CSaleDelivery::GetByID($val["DELIVERY_ID"]);
$zak = $zak."<tr><td align='left' colspan='3'><b>Доставка: </b>".$arDeliv["NAME"]."</td><td align='left'>".$val["PRICE_DELIVERY"]."</td></tr>";
$zak = $zak."</table>";
$arEventFields = array(
"ORDER_DATE" => $tim,
"ORDER_ID" => $ID,
"SOSTAV" => $zak,
"ORDER_USER" => $arUser_name,
"EMAIL" => $arUser,
"BCC" => $arUser,
"PRICE" => (int)$val["PRICE"]." руб",
"SALE_EMAIL" => "[email protected]",
);
CEvent::SendImmediate("SALE_NEW_ORDER", s1, $arEventFields, "N", 25);
}
}
Answer the question
In order to leave comments, you need to log in
Read through the new kernel, D7.
Offhand:
$order_obj=\Bitrix\Sale\Order::load( $order_id );
$basket= $order_obj->getBasket();
$basket_items=$basket->getBasketItems();
/* @var \Bitrix\Sale\BasketItem $bi */
foreach ( $basket_items as $bi ) {
$item_props= $bi->getPropertyCollection()->getPropertyValues();
}
Well, it's started!! )))
Have you completed the developer courses to the end or, as usual, did everything end at the introductory part?
What kind of property, I didn’t understand from the sheet, or rather reluctance to read ... The code would be written shorter, why ALL the sheet???!!
There is a component sale.order.detail.mail Inserted
into the mail template somehow like this
<? EventMessageThemeCompiler::includeComponent("bitrix:sale.personal.order.detail.mail", "template_name", array(
// параметры компонента
)) ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question