Answer the question
In order to leave comments, you need to log in
Why doesn't the OnBeforeOrderAdd event fire?
XML file not generated before adding product to cart
AddEventHandler("sale", "OnBeforeOrderAdd", "OnOrderAdd_item");
function OnOrderAdd_item()
{
//Создает XML-строку и XML-документ при помощи DOM
$dom = new DomDocument('1.0');
//добавление корня - <books>
$books = $dom->appendChild($dom->createElement('books'));
//добавление элемента <book> в <books>
$book = $books->appendChild($dom->createElement('book'));
// добавление элемента <title> в <book>
$title = $book->appendChild($dom->createElement('title'));
// добавление элемента текстового узла <title> в <title>
$title->appendChild(
$dom->createTextNode('Great American Novel'));
//генерация xml
$dom->formatOutput = true; // установка атрибута formatOutput
// domDocument в значение true
// save XML as string or file
$test1 = $dom->saveXML(); // передача строки в test1
$dom->save('test1.xml'); // сохранение файла
}
Answer the question
In order to leave comments, you need to log in
because when you call the handler function, you need to pass the SAME parameters to it as in the original function.
In your case:
We look at the documentation
and debug everything with debugging, maybe it enters, but does not simply create a file
1. no write permissions to php_interface?
2. sometimes I see there .htaccess with deny from all, check
3. in any case, there should be an error in the logs
Doesn't it bother you that the event for adding to the cart is called OnBeforeOrderAdd?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question