Answer the question
In order to leave comments, you need to log in
Bitrix controllers: how to access cart methods for unauthorized users?
I am writing a module that implements an API for interacting with the cart (the cart itself will be on react). I have methods for adding items to cart, removing items, listing, etc. for tests, I started the test.php page, on which methods from my module are called like this:
<button onclick="f1()">ADD</button>
function f1() {
let request = BX.ajax.runAction('mymodulename:controllers.sale.basketitem.add',
{
data: {
productId: 303,
quantity: 1,
}
}
);
request.then(function(response) {
console.log(response);
});
}
Answer the question
In order to leave comments, you need to log in
In general, the answer turned out to be to create a special method in the class:
public function configureActions(): array
{
return [
'update' => [
'-prefilters' => [
Authentication::class,
],
],
];
}
sessid: BX.bitrix_sessid(),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question