• andywt

    (@andywt)


    In my database, I have a money field that includes a monetary symbol ($) that comes from a Gravity form. When I tried to do the function “sum” on that field, it won’t add the field. To get around this i tried to use a transform function to remove the “$”:

    [cfdb-value form="Flag Database" trans="FlagLeasePrice=str_replace('$','',FlagLeasePrice)" function="sum" show="FlagLeasePrice"]

    but it made no difference.

    Any suggestions?

    https://wordpress.org/plugins/contact-form-7-to-database-extension/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    The single quotes don’t work. Try:
    [cfdb-value form="Flag Database" trans="FlagLeasePrice=str_replace($,,FlagLeasePrice)" function="sum" show="FlagLeasePrice"]

    If that doesn’t work, take out the function=”sum” to see what it is actually giving you for FlagLeasePrice.

    I’m not sure if function="sum" will play well with the transform. You might need to remove function=”sum” and replace it with a transform that does the sum.

    trans="FlagLeasePrice=str_replace($,,FlagLeasePrice)&&SumField(FlagLeasePrice)"

    Thread Starter andywt

    (@andywt)

    I changed the shortcode to `[cfdb-value form=”Flag Database” trans=”FlagLeasePrice=str_replace(“$”,””,FlagLeasePrice)” show=”FlagLeasePrice”]’
    and FlagLeasePrice continue to show the $.

    Plugin Author Michael Simpson

    (@msimpson)

    You didn’t take out the quotes. Try what I gave you.

    Thread Starter andywt

    (@andywt)

    Sorry Mike. Tried that and the FagLeasePrice goes to “”.
    Here is the printout without the transform:

    no transform printout

    Here is the shortcode with the transform and the printout:
    [cfdb-datatable form="Flag Database" trans="FlagLease=str_replace($,,FlagLeasePrice)" show="FlagLease"]
    transform printoiut

    Plugin Author Michael Simpson

    (@msimpson)

    I think there is a bug parsing that empty value. I’ll fix this shortly.

    Plugin Author Michael Simpson

    (@msimpson)

    Try it with version 2.10.2 which should be available in a little while.

    Thread Starter andywt

    (@andywt)

    Michael,
    The parsing issue is fixed but there seems to be another issue. I am using the cfdb-value to produce some stats about the database. I was using:

    [cfdb-value form="Flag Database" filter="payment_status=Paid"
    function="count" show="payment_status"]

    To count the number of records that are marked Paid. It produces a number but it doesn’t reconcile to what I compute using an Excel dump of the file. What I found was the filter does not work. I tried search and got the same result. I then change the shortcode to cfdb-datable with all the rest the same and the results show that the filter is not working. Here is a dump of the output:
    Filter Debug Dump

    I know the filter works as I use it to produce other reports.

    Plugin Author Michael Simpson

    (@msimpson)

    I’m not sure what is going on here. Make sure there is no line break inside the short code. If the filter part appears on a 2nd line, it might not be read.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Transform function’ is closed to new replies.