WordPress.org

Ready to get started?Download WordPress

Forums

Calculated Fields Form
[resolved] Individual value for choices - hidden value (14 posts)

  1. dcaccounting
    Member
    Posted 1 year ago #

    Is it possible to have this? I'll try to give an example, it seems to work like this currently:

    Item A: 10 - (ticked or selected from dropdown)
    Item B: 20 - (ticked or selected from dropdown)
    Item C: 40

    Total = 30

    I'm trying to achieve this:

    Item A - (ticked or selected from dropdown)
    Item B - (ticked or selected from dropdown)
    Item C

    Total = 30

    Kind regards

    Dean

    http://wordpress.org/extend/plugins/calculated-fields-form/

  2. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Dean,

    You should put the price into the text of the item so it can be identified and included in the calculation.

    An alternative to avoid placing the prices into the items is to use the ternary operator but that way the formula will become more complex and it depends of the complexity of your form, so the recommended way is to put the price as part of the text.

    Thank you for using the plugin!

  3. dcaccounting
    Member
    Posted 1 year ago #

    Perhaps you might think about including a 'pre-defined' value per line item in a future update?

    Regards

    Dean

  4. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, that's in the TO-DO list for a future update.

    Thank you for your comments!

  5. dcaccounting
    Member
    Posted 1 year ago #

    Actually, could you give me an example of how the ternary operator would work on the above example?

    Regards

    Dean

  6. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    The sample form "Ideal Weight Calculator" included in the plugin makes use of the ternary operator.

    If you want a more specific sample, please post a support request at http://wordpress.dwbooster.com/contact-us and include a link to the page that contains your form to give you a sample rule according to your form configuration.

    Thank you!

  7. dcaccounting
    Member
    Posted 1 year ago #

    Thanks, I might just have to do that!

    One last quick question; when you use the dropdown box method, the total doesn't update until all boxes have been selected?

    Regards

    Dean

  8. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    At least one value should be selected/edited in each box/field used in the calculation in order to be able to complete the calculation. You can set a default value for each field so you don't have to fill all of them before getting a result.

    Thank you!

  9. dcaccounting
    Member
    Posted 1 year ago #

    How do you set a default value of zero until something is selected. I have something that looks like this:

    Please select (so this is displayed in the box field)
    No - Item A: 10
    Yes - Item B: 50
    Yes - Item C: 100

    Regards

    Dean

  10. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    If you are using the latest version (published today) you can use this formula:

    (fieldname5>='A'?0:fieldname5)

    Note: The field was referenced as "fieldname5" for this sample. Replace that with the real name of the field in your form.

    That way if a text without numbers is selected then a 0 will be used as value, otherwise the number in the field will be used.

    That's a workaround for the current version. The feature for adding hidden values to the fields is still in the TO-DO list.

    Thank you!

  11. dcaccounting
    Member
    Posted 1 year ago #

    I'm using this:

    (fieldname11>='Please seclect'?0:fieldname11)

    It doesn't work. Are you saying I need to do this:

    (fieldname11>='Please seclect'?0:No - Item A: 10, Yes - Item B: 50, Yes - Item C: 100)

    So that when 'please select' is shown it will give a nil value and when someone selects something else it'll show that value instead.

    Regards

    Dean

  12. codepeople
    Member
    Plugin Author

    Posted 1 year ago #

    You should use exactly this:

    (fieldname11>='A'?0:fieldname11)

    ... comparing it to the uppercase 'A' will cover any text into the field. If the problem persists please open a ticket at http://wordpress.dwboster.com/contact-us to check the problem in detail.

    Thank you!

  13. dcaccounting
    Member
    Posted 1 year ago #

    Thank you! :D

    Regards

    Dean

  14. s-d-c
    Member
    Posted 1 year ago #

    I'm just getting into this plugin.
    I figured out you can nest the javascript ternary operators.

    Let's say I am using Flat Rate shipping boxes and all the items for this form are identically sized.

    1 item = $6.95 shipping.
    2 through 8 items (fits in the next box size) = $17.95 shipping.
    9 through 16 items (fits in 2 of those boxes) = $35.90 shipping.

    fieldname8 is a "shipping" or "store pickup" dropdown.
    fieldname9 is a 'total items being shipped'.

    This works:

    (fieldname8=='Store Pickup'?0:1)*(fieldname9==1?6.95:(fieldname9>8?35.90:(fieldname9>1?17.95:0)))

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.