add hook getBuyPrice (#27420)

This commit is contained in:
Frédéric FRANCE 2024-01-12 20:43:00 +01:00 committed by GitHub
parent 0d3e0c8ec4
commit 8aa4a515dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2088,7 +2088,24 @@ class Product extends CommonObject
public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0)
{
// phpcs:enable
global $conf;
global $action, $hookmanager;
// Call hook if any
if (is_object($hookmanager)) {
$parameters = array(
'prodfournprice' => $prodfournprice,
'qty' => $qty,
'product_id' => $product_id,
'fourn_ref' => $fourn_ref,
'fk_soc' => $fk_soc,
);
// Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('getBuyPrice', $parameters, $this, $action);
if ($reshook > 0) {
return $hookmanager->resArray;
}
}
$result = 0;
// We do a first search with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref)