Created
August 9, 2019 19:14
-
-
Save madcatgith/5458696e12a8eae00ac4579136d93eeb to your computer and use it in GitHub Desktop.
[BITRIX] Подмена родительского класса компонента ядра
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once('../../../../bitrix/components/bitrix/sale.order.ajax/class.php'); | |
use \Bitrix\Sale\Order; | |
use \Bitrix\Sale\BasketBase; | |
/** | |
* Подмена родительского класса компонента ядра | |
* в данном частном случае размещается в файле local/components/bitrix/sale.order.ajax/class.php | |
* | |
* @author Vladimir Tikunov <[email protected]> | |
*/ | |
class SaleOrderAjaxLaptop extends SaleOrderAjax | |
{ | |
private $isChangePersonType = false; | |
protected function initPersonType(Order $order) | |
{ | |
$result = parent::initPersonType($order); | |
$this->isChangePersonType = !!$result; | |
return $result; | |
} | |
protected function initBasket(Order $order) | |
{ | |
parent::initBasket($order); | |
if (!$this->isChangePersonType) { | |
return; | |
} | |
$basket = $order->getBasket(); | |
if (!$basket instanceof BasketBase) { | |
return; | |
} | |
foreach ($basket->getIterator() as $item) { | |
$isCustomPrice = $item->getField('CUSTOM_PRICE') === 'Y'; | |
if ($isCustomPrice) { | |
$productId = $item->getProductId(); | |
$item->setPrice('ЗДЕСЬ НАДО ЦЕНУ ПО ID'); | |
$item->setField('CUSTOM_PRICE', 'N'); | |
continue; | |
} | |
$currentPrice = $item->getPrice(); | |
$item->setPrice('ЗДЕСЬ НАДО ФОРМУЛУ'); | |
$item->setField('CUSTOM_PRICE', 'Y'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment