Not a programmer, I am trying my best to customise my Dolibarr.
In case that Customers have different billing and shipping names / addresses (Billing To / Shipping To), I have to identify these different recipient names / addresses. However, I didn’t find a sales order template to indicate all the information, although I specified the billing (invoice) and shipping contacts, as well as Customer’s representative for order follow-up.
Therefore, I tried to add complementary attributes to Sales Order, to fetch these billing / shipping contacts and their respective Third-Party names. For the computed field, I have tried the follows:
-
$object->getIdContact(‘external’, ‘BILLING’)[0] and $object->getIdContact(‘external’, ‘SHIPPING’)[0], which can fetch the billing and shipping contact id respectively.
-
Then I tried the formula below to fetch the fk_soc (contact’s Third Party name), which does not work at all.
a) (($reloadcontact = new Contact($db)) && ($reloadcontact->fetch($object->getIdContact(‘external’, ‘SHIPPING’)[0])>0)) ? $reloadcontact->fk_soc: ‘-1’
b) (($reloadcontact = new Contact($db)) && ($reloadcontact->fetch_contact($object->getIdContact(‘external’, ‘SHIPPING’)[0])>0)) ? $reloadcontact->fk_soc: ‘-1’
After trying differrent ways, it seems to me that $reloadcontact = new Contact($db) may be wrong. However, I don’t know how to resolve it. Can anyone help me? -
I already tried the formula below to fetch the Third-Party name, which was working If $id is a specified value:
(($reloadSoc= new Societe($db))&&($reloadSoc->fetch($id)>0))?$reloadcontact->nom:’-1’
Can anyone help me on Item 2 above? Or maybe you know an existing function or property of $object to achieve my objective?
Thanks a lot.