PHP
1
Вклад в тег
// Создаем заказ и привязываем корзину
$order = Order::create(SITE_ID, $USER_ID);
$order->setPersonTypeId($SOME_PERSON_TYPE_ID);
$basket = Sale\Basket::loadItemsForFUser(Sale\Fuser::getId(), Bitrix\Main\Context::getCurrent()->getSite());
$price = $basket->getPrice();
$fullPrice = $basket->getBasePrice();
$order->setBasket($basket);
// Добавляем Доставку(Отгрузку?)
$shipmentCollection = $order->getShipmentCollection();
$shipment = $shipmentCollection->createItem(
Bitrix\Sale\Delivery\Services\Manager::getObjectById($SOME_DELIVERY_TYPE_ID)
);
// Отгрузку наполняем товарами из корзины
$shipmentItemCollection = $shipment->getShipmentItemCollection();
foreach ($basket as $basketItem) {
$item = $shipmentItemCollection->createItem($basketItem);
$item->setQuantity($basketItem->getQuantity());
}
// PAYMENT
$arPaySystemServiceAll = [];
$paymentCollection = $order->getPaymentCollection();
$extPayment = $paymentCollection->createItem();
$extPayment->setField("SUM", $order->getPrice());
$arPaySystemServiceAll = Sale\PaySystem\Manager::getListWithRestrictions($extPayment);
reset($arPaySystemServiceAll);
$arPaySystem = current($arPaySystemServiceAll);
if(!empty($arPaySystem)) {
$extPayment->setFields(array(
"PAY_SYSTEM_ID" => $arPaySystem["ID"],
"PAY_SYSTEM_NAME" => $arPaySystem["NAME"]
));
} else
$extPayment->delete();
$arPaySystemServiceAll;