E
E
Evgeny Nikolaev2019-07-04 11:23:55
1C-Bitrix
Evgeny Nikolaev, 2019-07-04 11:23:55

Class 'Bitrix\Sale\Basket' not found (if you connect plog, but if you connect header.php it works). How to connect?

If you connect like this:
<?php
require $_SERVER['DOCUMENT_ROOT'].' /bitrix/modules/main/include/prolog_before.php ';
use Bitrix\Main\Context,
Bitrix\Currency\CurrencyManager,
Bitrix\Sale\Order,
Bitrix\Sale\Basket,
Bitrix\Sale\Delivery,
Bitrix\Sale\PaySystem,
YandexCheckout\Client;
$basket = \Bitrix\Sale\Basket::loadItemsForFUser (\Bitrix\Sale\Fuser::getId(CSaleBasket::GetBasketUserID()), \Bitrix\Main\Context::getCurrent()->getSite());
then an error message appears:
[Error]
Class 'Bitrix\Sale\Basket' not found (0)

And if like this:
<?php
require($_SERVER["DOCUMENT_ROOT"]." /bitrix/header.php ");
use Bitrix\Main\Context,
Bitrix\Currency\CurrencyManager,
Bitrix\Sale\Order,
Bitrix\Sale\Basket,
Bitrix\Sale\Delivery,
Bitrix\Sale\PaySystem,
YandexCheckout\Client;
$basket = \Bitrix\Sale\Basket::loadItemsForFUser (\Bitrix\Sale\Fuser::getId(CSaleBasket::GetBasketUserID()), \Bitrix\Main\Context::getCurrent()->getSite());
That's all right. Only in the task I don’t need the site header, since the ajax API is being written to calculate deliveries. How to make the Basket class visible when including require $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php';

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Nikolaev, 2019-07-04
@nikolaevevge

Got it!
After use, I forgot to write:
Bitrix\Main\Loader::includeModule("sale");
Bitrix\Main\Loader::includeModule("catalog");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question