Created
August 20, 2021 08:15
-
-
Save luckydevilru/8e63c6630e3fd2c460f5411b7aff1362 to your computer and use it in GitHub Desktop.
Создание отгрузки из заказа сделки bitrix24. Create shipment from order deal bitrix bitrix24 битрикс
This file contains hidden or 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
<? | |
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true){ | |
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"); | |
} | |
// 1. получаем заказ | |
$order = \Bitrix\Sale\Order::load($order_id); | |
// 2. получаем корзину заказа | |
$basket = $order->getBasket(); | |
// 3. список отгрузок - хз зачем | |
$collection = $order->getShipmentCollection(); | |
// 4. создаем отгрузку | |
$shipment = $collection->createItem(); | |
// 5. вообще нахера он нужен | |
$shipmentItemCollection = $shipment->getShipmentItemCollection(); | |
// 6. для каждого товара из корзины | |
foreach ($basket as $basketItem) | |
{ | |
// 7. создаем хз что с товаром | |
$item = $shipmentItemCollection->createItem($basketItem); | |
// 8. и этому хз указываем количество товара. | |
$item->setQuantity($basketItem->getQuantity()); | |
} | |
$r = $shipment->setFields([ | |
'ALLOW_DELIVERY' => 'Y', // РАЗРЕШЕНО ОТГРУЗКА | |
'DEDUCTED' => 'Y', // ОТГРУЖЕН | |
'STATUS_ID' => 'DF' // СТАТУС | |
]); | |
$order->save(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment