Bitrix-D7  20.5.0
sale/lib/helpers/order.php
См. документацию.
1 <?php
2 namespace Bitrix\Sale\Helpers;
3 
5  Bitrix\Sale,
8 
9 class Order
10 {
11  /**
12  * Check ability to view order is not an authorized user
13  *
14  * @param Sale\Order $order
15  *
16  * @return bool
17  * @throws \Bitrix\Main\ArgumentNullException
18  */
19  public static function isAllowGuestView(Sale\Order $order)
20  {
21  $guestStatuses = Option::get("sale", "allow_guest_order_view_status", "");
22  $guestStatuses = ($guestStatuses <> '') ? unserialize($guestStatuses) : array();
23  return (is_array($guestStatuses) && in_array($order->getField('STATUS_ID'), $guestStatuses) && Option::get("sale", "allow_guest_order_view") === 'Y');
24  }
25 
26  /**
27  * Return link to order for an unauthorized users.
28  *
29  * @param Sale\Order $order
30  *
31  * @return string
32  * @throws \Bitrix\Main\ArgumentException
33  * @throws \Bitrix\Main\ArgumentNullException
34  */
35  public static function getPublicLink(Sale\Order $order)
36  {
37  $context = Application::getInstance()->getContext();
38  $scheme = $context->getRequest()->isHttps() ? 'https' : 'http';
39  $siteData = SiteTable::getList(array(
40  'filter' => array('LID' => $order->getSiteId()),
41  ));
42  $site = $siteData->fetch();
43 
44  $paths = unserialize(Option::get("sale", "allow_guest_order_view_paths"));
45  $path = htmlspecialcharsbx($paths[$site['LID']]);
46 
47  if (isset($path) && mb_strpos($path, '#order_id#'))
48  {
49  $accountNumber = urlencode(urlencode($order->getField('ACCOUNT_NUMBER')));
50  $path = str_replace('#order_id#', $accountNumber,$path);
51  if (mb_strpos($path, '/') !== 0)
52  {
53  $path = '/'.$path;
54  }
55 
56  $path .= (mb_strpos($path, '?')) ? '&' : "?";
57  $path .= "access=".$order->getHash();
58  }
59  else
60  {
61  return "";
62  }
63 
64  return $scheme.'://'.$site['SERVER_NAME'].$path;
65  }
66 }
Base class for any application.
static getInstance()
Returns current instance of the Application.
static get($moduleId, $name, $default="", $siteId=false)
Returns a value of an option.
static getPublicLink(Sale\Order $order)
Return link to order for an unauthorized users.
static isAllowGuestView(Sale\Order $order)
Check ability to view order is not an authorized user.
Class RestHandler \Handlers\PaySystem.