Answer the question
In order to leave comments, you need to log in
Why is the price (API) not transmitted when placing an order in 1 click?
Hello.
If you place a "Quick order" for the current user, receiving a basket like this:
$basket = Sale\Basket::loadItemsForFUser(Sale\Fuser::getId(), Bitrix\Main\Context::getCurrent()->getSite());
$ID = 520747;
$price = CPrice::GetBasePrice($ID)['PRICE'];
$products = array(
array(
'PRODUCT_ID' => $ID,
'NAME' => "Бс-100/24",
'PRICE' => $price,
'CURRENCY' => 'RUB',
'QUANTITY' => 1
)
);
$basket = Bitrix\Sale\Basket::create(SITE_ID);
foreach ($products as $product)
{
$item = $basket->createItem("dress_catalog", $product["PRODUCT_ID"]);
unset($product["PRODUCT_ID"]);
$item->setFields($product);
}
Answer the question
In order to leave comments, you need to log in
Try my code:
$basket = \Bitrix\Sale\Basket::create('s3');
$basket = $basket->getOrderableItems();
foreach ($basket as $item) {
$item->getItemById($id)->delete();
}
$item = $basket->createItem("catalog", $id);
$item->setFields(array(
'PRODUCT_ID' => $id,
'CURRENCY' => 'RUB',
'QUANTITY' => $quantity,
'LID' => SITE_ID,
'PRODUCT_PROVIDER_CLASS' => '\CCatalogProductProvider'
));
// order
$order = \Bitrix\Sale\Order::create(SITE_ID, $USER->isAuthorized() ? $USER->GetID() : $ID);
$order->setPersonTypeId(5);
$order->setBasket($basket);
//shippment collection
$shipColl = $order->getShipmentCollection();
$shipp = $shipColl->createItem(\Bitrix\Sale\Delivery\Services\Manager::getObjectById(1));
$shipColl = $shipp->getShipmentItemCollection();
foreach ($basket as $basketItem) {
$item = $shipColl->createItem($basketItem);
$item->setQuantity($basketItem->getQuantity());
}
//props
$propsColl = $order->getPropertyCollection();
$order->setField('COMMENTS', 'Это быстрый заказ. Нужно перезвонить клиенту.');
$phoneProp = $propsColl->getPhone();
$phoneProp->setValue($phone);
$nameProp = $propsColl->getProfileName();
$nameProp->setValue($name);
$emailProp = $propsColl->getUserEmail();
$emailProp->setValue($email);
// pay
$payColl = $order->getPaymentCollection();
$payment = $payColl->createItem(\Bitrix\Sale\PaySystem\Manager::getObjectById(13));
$payment->setField("SUM", $order->getPrice());
$payment->setField("CURRENCY", $order->getCurrency());
//save
$order->save();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question