• Resolved Drake

    (@marcoragogna)


    Hello,
    I found this plugin while searching for a calculation plugin.
    I have a question, is it possible in some way to perform calculation based on tables.

    I’ll try to explain my needs more in details.

    I need to build a vehicle booking system where the customer select the departure and the destination city. But the calculation is not based on km but everything is fixed and store in some tables.

    Table 1
    FROM A to B cost X
    FROM A to C cost X
    FROM A to D cost X

    Table 2
    FROM B to A cost X
    FROM B to C cost X

    and so on.

    Is this plugin capable of manage this scenario? I tried the demo and I was not able to build something like this but maybe I miss something.

    Thank you in advance for the answer

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello,

    In this case you need to define an array of objects, where each object includes the origin, destination and cost.

    Assuming the fields for origin and destination are: fieldname1 and fieldname2, the equation associated to the calculated field would be similar to:

    (function(){
    var db = [
    {from: 'A', to: 'B', cost: 123},
    {from: 'A', to: 'C', cost: 213},
    {from: 'A', to: 'D', cost: 34},
    {from: 'B', to: 'C', cost: 565},
    {from: 'B', to: 'D', cost: 232},
    {from: 'C', to: 'D', cost: 55}
    ];
    
    for(var i in db)
    {
    if((db[i]['from'] == fieldname1 && db[i]['to'] == fieldname2) || (db[i]['from'] == fieldname2 && db[i]['to'] == fieldname1)) return db[i]['cost'];
    }
    return '';
    })()

    of course, defining the array with the real values.

    The data can be stored in an external datasource, like a database or CSV file, but in this case would be required the Developer or Platinum versions of the plugin.

    Best regards.

    Thread Starter Drake

    (@marcoragogna)

    Thank you for the reply. If it is possible with Developer or Platinum version of the plugin I will for sure consider it.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    The explanation in the previous ticket is compatible with all versions of the plugin, even the free version.

    The implementation with the Developer or Platinum version will depend of data source’s structure.

    Best regards.

    Thread Starter Drake

    (@marcoragogna)

    Thank you, you are right, I tried starting from your example and everything working as expected. In any case I will probably end up buying the Pro o Developer version because I need to perform the PayPal payment and send emails.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Table based calculation are possible?’ is closed to new replies.