PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Stripping pipe delimiter from Product Field

  1. silk
    Member

    The Product field includes two values separated by a pipe delimiter. Is it possible to remove or replace this delimiter using gform_after_submission?

    My form (ID 6) contains ten product fields. I tried adding this code to my custom functions.php but it doesn't work:

    add_action("gform_after_submission_6", "after_submission", 10, 2);
    $entry = str_replace("|", "~", $entry);

    Could someone please suggest the code I should use - I'm a beginner. Thanks, it's a great product!

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  2. There is currently no way to strip or replace the delimiter in the Product Field. It functions like this by design. Form fields only have one value, but a Pricing Field is unique and necessitates multiple values (the name and the price) which requires the information to be stored this way.

    Without the pipe there would be no way to store 1) What was selected and 2) The price of what was selected. So it's critical that this is not changed for Pricing Fields to function properly.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  3. silk
    Member

    I understand the pricing field needs the delimiter to function. I want to remove it after it has done its work, when I am sending the field to other progs via their API.

    I thought gform_after_submission did this?

    Thanks.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  4. What you would have to do is when using gform_after_submission and getting that value, you'd then have to parse that field and just get the piece of the data you want and then pass just that to the 3rd party API.

    So you'd have to parse the value and just get the portion of the data you need from that field value. You wouldn't actually change what is stored in the entry. You would manipulate the data before passing it to the API.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  5. silk
    Member

    Yes, that's what I want to do.

    So could you please suggest the code I should use to replace the pipe with a tilde?

    I tried

    add_action("gform_after_submission_6", "after_submission", 10, 2);
    2	$entry = str_replace("|", "~", $entry);

    That did nothing. What do you suggest?

    Thanks.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  6. You are going about this wrong. You don't want to update the value of the entry. You only want to pass the manipulated value to the 3rd party API.

    So whatever code you are using to pass the value of that field to the 3rd party API, that is where you want to do the string replace.

    The code you have above is trying to do a string replace on the entire entry object, which isn't going to work.

    Posted 12 years ago on Monday December 19, 2011 | Permalink
  7. silk
    Member

    Ok, I see. Thanks Carl.

    Posted 12 years ago on Saturday December 24, 2011 | Permalink

This topic has been resolved and has been closed to new replies.