Answer the question
In order to leave comments, you need to log in
How do I add a deactivated item to the cart?
People, help. Add items to cart using the following code:
if(!empty($_POST['ADD'])) {
$itemID = intval($_POST['ADD']);
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
$count = 1;
if(!empty($_POST['QUANTITY'])) {
$count = $_POST['QUANTITY'];
}
Add2BasketByProductID($itemID, $count);
echo json_encode(array(0=>$itemID));
}
Answer the question
In order to leave comments, you need to log in
callback is triggered, you need to pass Add2BasketByProductID 3 as a parameter
$arRewriteFields = array(
'CALLBACK_FUNC' => '',
'ORDER_CALLBACK_FUNC' => '',
'CANCEL_CALLBACK_FUNC' => '',
'PAY_CALLBACK_FUNC' => '',
'PRODUCT_PROVIDER_CLASS' => '',
);
I inserted the 3rd parameter and no more product wants to be added to the cart.
if(!empty($_POST['ADD'])) {
$itemID = intval($_POST['ADD']);
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");
$count = 1;
if(!empty($_POST['QUANTITY'])) {
$count = $_POST['QUANTITY'];
}
$arRewriteFields = array(
'CALLBACK_FUNC' => '',
'ORDER_CALLBACK_FUNC' => '',
'CANCEL_CALLBACK_FUNC' => '',
'PAY_CALLBACK_FUNC' => '',
'PRODUCT_PROVIDER_CLASS' => '',
);
Add2BasketByProductID($itemID, $count, $arRewriteFields);
echo json_encode(array(0=>$itemID));
}
I don’t know how relevant the answer is, but I’ll give you more advice - internal manipulations should not break the Bitrix mechanisms.
If you need to hide a product out of sight but leave the ability to add to the cart, then create a filter with some product property in the $arrFilter global variable in init.php.
Activity is used in a large number of mechanisms. And besides, your approach complicates the further support of the site.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question