Hello, tell me the function of which you can change the payment flag to "paid." I try to do the following, if the order amount is equal to or less than 0, then the order is "PAID".

in the file bitrix / php_interface / s1 / init.php I write

<?php AddEventHandler('sale',"OnOrderUpdate" , 'PayedIfNoEMoney'); function PayedIfNoEMoney( $orderId , $arFields='' , $arOrder='' ) { if($arFields["PRICE"] <= 0){ CSaleOrder::StatusOrder($orderId, 'Y'); CSaleOrder::PayOrder($ID, "Y"); } } ?> 

but only the payment status changes, and the flag remains "unpaid"

tell me how to change the payment flag? enter image description here

    1 answer 1

    You have not declared $ID variable, correct the line:

      CSaleOrder::PayOrder($orderId, "Y"); 
    • thank you so much! A few days tormented by this! - Serhiy Bilik
    • @SerhiyBilik I advise you to use ide (for example phpstorm). Helps to avoid such errors. - Dmitry
    • I will listen to your advice! now using netbeans - Serhiy Bilik