• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/compatible/ordercompatibility.php
  • Класс: BitrixSaleCompatibleOrderCompatibility
  • Вызов: OrderCompatibility::addBasketRuntime
protected function addBasketRuntime($key)
{
	$output = null;

	if ($key == "BASKET_DISCOUNT_COUPON")
	{
		if (!in_array('COUPONS', $this->runtimeFields))
		{
			$this->query->registerRuntimeField(
				'COUPONS',
				array(
					'data_type' => 'BitrixSaleInternalsOrderCouponsTable',
					'reference' => array(
						'=ref.ORDER_ID' => 'this.ID'
					),
				)
			);
			$this->runtimeFields[] = "COUPONS";
		}

		$this->addQueryAlias('BASKET_DISCOUNT_COUPON', 'COUPONS.COUPON');
		$output = 'BASKET_DISCOUNT_COUPON';

	}
	elseif ($key == "BASKET_DISCOUNT_NAME")
	{
		if (!in_array('DISCOUNT_ORDER_RULES', $this->runtimeFields))
		{
			$this->query->registerRuntimeField(
				'DISCOUNT_ORDER_RULES',
				array(
					'data_type' => 'BitrixSaleInternalsOrderRulesTable',
					'reference' => array(
						'=ref.ORDER_ID' => 'this.ID',
					),
				)
			);
			$this->runtimeFields[] = "DISCOUNT_ORDER_RULES";
		}

		if (!in_array('DISCOUNT', $this->runtimeFields))
		{
			$this->query->registerRuntimeField(
				'DISCOUNT',
				array(
					'data_type' => 'BitrixSaleInternalsOrderDiscountTable',
					'reference' => array(
						'=ref.ID' => 'this.DISCOUNT_ORDER_RULES.ORDER_DISCOUNT_ID'
					),
				)
			);

			$this->runtimeFields[] = "DISCOUNT";
		}

		$this->addQueryAlias('BASKET_DISCOUNT_NAME', 'DISCOUNT.NAME');
		$output = 'BASKET_DISCOUNT_NAME';
	}

	return $output;
}