better hook management

This commit is contained in:
Christophe Battarel 2022-07-26 15:38:50 +02:00
parent 3f04a91b07
commit 0c416a1e38

View File

@ -562,14 +562,16 @@ if (empty($reshook)) {
$invoice->fetch_thirdparty();
$array_options = array();
$line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'locatax1_tx' => $localtax1_tx, 'locatax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
// complete line by hook
$parameters = array('prod' => $prod);
$reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action);
$parameters = array('prod' => $prod, 'line' => $line);
$reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
$idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $array_options, 100, '', null, 0);
}
if (!empty($hookmanager->resArray)) $line = $hookmanager->resArray;
$idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $line['array_options'], 100, '', null, 0);
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {
$CUSTOMER_DISPLAY_line1 = $prod->label;