Difficulty Finding API Route to Set Customer-Specific Pricing in Dolibarr

I’ve been tasked with setting customer-specific pricing through the Dolibarr API. However, after thorough exploration, I’ve found that while there is a GET method available to retrieve pricing information that has been manually added through the Dolibarr interface (GET /products/{id}/selling_multiprices/per_customer ), I haven’t been able to locate a corresponding API route to set or update this pricing programmatically.
This limitation has hindered my progress in automating the pricing management process, as I need to dynamically adjust pricing based on customer profiles and other factors.
I’ve checked the Dolibarr documentation and conducted online searches, but unfortunately, I haven’t been able to find a solution to this issue.
I would greatly appreciate any guidance or assistance you can provide in resolving this matter. If you have a moment to discuss further or provide any pointers, please let me know at your earliest convenience.

1 Like

@Souhail yeah that seems true that the API even in the develop branch can only get that price.

I recently expanded API functionality and it is not complicated.

I am not using multipricing, so I don’t know if it is available inside the Dolibarr GUI, but if it is available, then surely there are already functions that can do that and you basically only need to get the API to use them. That is what I did for a lot of my extensions. Like when I wanted to extend the API setup extrafields which also only existed in GET I found and reused functions that the Dolibarr GUI already used.

Pull requests here: Pull requests · Dolibarr/dolibarr · GitHub

I would start with checking these files for public functions

  • htdocs/product/class/api_products.class.php
  • htdocs/product/class/product.class.php

And look at this, there is a directory called dynamic_price - that is probably also a place to explore

  • htdocs/product/dynamic_price/

Finally if inside the GUI there is a page that does what you want, then find the corresponding file under htdocs, Eg. http://localhost/product/price.php?id=1 is htdocs/product/price.php

and http://localhost/product/fournisseurs.php?id=1 is this file product/fournisseurs.php

So check what functions these files are using.

Also, enable debug logs in dolibarr, and tail -f documents/dolibarr.log + watch the PHP/Apache log files. And finally I recommend a database tool like phpMyAdmin.

My development setup is tuxgasy dolibarr container image + latest mariadb container image + latest phpMyAdmin container image. I run each inside a container which is bound inside a podman pod, and then I either use podman desktop or I use the terminal to start, configure, enter, tail and log the dolibarr container - the other containers I don’t enter but I do visit the webpage of phpMyAdmin.

1 Like

Thanks for sharing this setup for development. :star_struck:
I’m going to try to hack on the API so it gets the features I need.

1 Like