G
G
Good Samaritan2016-02-29 23:13:09
PHP
Good Samaritan, 2016-02-29 23:13:09

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'); // сохранение файла 

}

but in folder php_interface XML FILE IS NOT CREATED

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rad1calDreamer, 2016-03-01
@Rad1calDreamer

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

J
JohnDaniels, 2016-03-01
@JohnDaniels

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

O
Oleg Maksimenko, 2016-03-01
@olegprof

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 question

Ask a Question

731 491 924 answers to any question