Announcement

Collapse
No announcement yet.

Quotes items: Get item price from external API via AJAX request - best practice?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quotes items: Get item price from external API via AJAX request - best practice?

    Hello,

    my products items prices are variable, depending on given size (length, width).
    For that I plan to use sales extension with let's say two custom fields (length, width) in quotes item view.
    Calculation is too complex for fomula so prices have to be retrieved by calling an external API using some parameters.

    What I'm looking for is the best practice in espoCRM for implementing
    an external AJAX request in quotes item view.
    I'm aware of AJAX cross-domain restrictions, that's not the point (should work with reverse-proxy)


    Steps should be:

    - Open HTTPS-Connection to external cross-domain API
    - Authentication: Basic or API-Key
    - All REST methods should be possible, with GET being the most important one
    - Request then sends length & width and gets resulting item price
    - Resulting price goes into form field data-name='item-amount' (the item sum field)


    Is there a way doing that with a hook?
    Or is it the best way to start from a field formula?
    Or better go for custom code in /custom/...

    Of course implementation should survive espoCRM updates (core & extensions).



    Thanks in advance!
Working...
X