Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/php_interface/lib/ |
Upload File : |
<?php namespace Wbs24; use Bitrix\Main\Loader; class EmailFields { protected $CIBlockElement = false; public function __construct($objects = []) { if (Loader::includeModule('iblock')) { $this->CIBlockElement = $objects['CIBlockElement'] ?? new \CIBlockElement(); } } public function getHtmlOrderList($orderId) { $html = ''; $order = \Bitrix\Sale\Order::load($orderId); $basket = $order->getBasket(); foreach ($basket as $basketItem) { $name = $basketItem->getField('NAME'); $quantity = $basketItem->getQuantity(); $price = CurrencyFormat($basketItem->getPrice(), 'RUB'); $productId = $basketItem->getProductId(); $productInfo = $this->getProductInfo($productId); $picture = $productInfo['PREVIEW_PICTURE_PATH'] ?? ''; $site = 'http'.($_SERVER['HTTPS'] ? 's' : '').'://'.$_SERVER['HTTP_HOST']; $url = $productInfo['DETAIL_PAGE_URL'] ?? ''; $html .= "<div style='margin: 10px 0;'> <a href='${site}${url}'><img style='width: 100px; max-height: 100px;' src='${site}${picture}'></a> <a href='${site}${url}'><span>${name}</span></a> <span> - ${quantity} шт x ${price}<span> </div>\r\n" ; } return $html; } protected function getProductInfo($productId) { if (!$this->CIBlockElement) return; $product = []; $select = ["ID", "IBLOCK_ID", "PREVIEW_PICTURE", "DETAIL_PAGE_URL"]; $filter = ["ACTIVE" => "Y", "ID" => $productId]; $result = $this->CIBlockElement->GetList(["SORT" => "ASC"], $filter, false, false, $select); if ($fields = $result->GetNext()) { $product = [ 'PREVIEW_PICTURE_PATH' => \CFile::GetPath($fields["PREVIEW_PICTURE"]), 'DETAIL_PAGE_URL' => $fields['DETAIL_PAGE_URL'], ]; } return $product; } }