Created
April 19, 2020 13:13
-
-
Save gromdron/f8545e0993bae6a51a183c54d59a0280 to your computer and use it in GitHub Desktop.
get invoice items
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
use \Bitrix\Main; | |
use \Bitrix\Sale; | |
use \Bitrix\Crm\Invoice; | |
try | |
{ | |
if ( ! Main\Loader::IncludeModule('crm') ) | |
{ | |
throw new \Exception("CRM module not inluded"); | |
} | |
if ( !Main\Loader::IncludeModule('sale') ) | |
{ | |
throw new \Exception("Sale module not included"); | |
} | |
$invoiceId = 3; | |
$registry = Sale\Registry::getInstance( Invoice\Invoice::getRegistryType() ); | |
$invoiceClass = $registry->get( Sale\Registry::ENTITY_ORDER ); | |
$invoice = $invoiceClass::load($invoiceId); | |
// Получаем товары | |
$invoiceItems = $invoice->getBasket(); | |
foreach ($invoiceItems as $invoiceBasketItem) | |
{ | |
var_dump($invoiceBasketItem->getField('NAME')); | |
var_dump($invoiceBasketItem->getFinalPrice()); | |
} | |
} | |
catch( \Exception $e ) | |
{ | |
var_dump($e->getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment