Created
February 4, 2019 14:24
-
-
Save VSeryoga/03d8613fb51c14e314d2cd837c0fc1bb to your computer and use it in GitHub Desktop.
Добавление товара в заказ и пересчет скидки по купону
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
<? | |
\Bitrix\Main\Loader::includeModule('sale'); | |
$order = \Bitrix\Sale\Order::load(36065); | |
$basket = $order->getBasket(); | |
\Bitrix\Sale\DiscountCouponsManager::init( | |
\Bitrix\Sale\DiscountCouponsManager::MODE_ORDER, array('orderId' => $order->getId(), 'userId' => $order->getUserId()) | |
); | |
$basketItem = $basket->createItem('catalog', 456279); | |
$fields = array( | |
'QUANTITY' => 2, | |
'PRODUCT_PROVIDER_CLASS' => '\\Bitrix\\Catalog\\Product\\CatalogProvider' | |
); | |
$basketItem->setFields($fields); | |
$refreshStrategy = \Bitrix\Sale\Basket\RefreshFactory::create(\Bitrix\Sale\Basket\RefreshFactory::TYPE_FULL); | |
$result = $basket->refresh($refreshStrategy); | |
$r = $order->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment