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.

User Created Product

  1. brad13x
    Member

    I need to allow a user to create their own product (just a blank text field?), price and quantity and have it show up correctly in the order form portion of the email. Is this possible? If so how?

    Thanks

    Brad

    Posted 12 years ago on Thursday July 21, 2011 | Permalink
  2. Currently it's possible to allow the user to input the quantity and user defined price, but the Product Name is currently not populated from a field. But this would be possible via a customization using code to set the Product Name to use a value from another Input Field. How comfortable are you with PHP and the use of WordPress hooks/filters to customize things?

    Posted 12 years ago on Thursday July 21, 2011 | Permalink
  3. brad13x
    Member

    Very comfortable could you give me a crude example.

    Posted 12 years ago on Thursday July 21, 2011 | Permalink
  4. brad13x
    Member

    Any love? :P

    Posted 12 years ago on Friday July 22, 2011 | Permalink
  5. You would use the gform_post_submission hook to update and change the name of the product to use the value they input in the text field you use to let them enter the name. The gform_post_submission hook is documented here:

    http://www.gravityhelp.com/documentation/page/Gform_post_submission

    Posted 12 years ago on Friday July 22, 2011 | Permalink
  6. brad13x
    Member

    I don't know if the post submission documentation will help. That just permanently changes the value of a post. Maybe I'm missing something?

    I'm trying to add the values of the "Product" field to the order form that is mailed to the email on the Notifications tab using values supplied by the user.

    So we get
    <email form>
    Name user info etc.

    Order form
    12 widgets $1200
    1 blue widget $1.00

    </end email>

    Please look at my form here. http://dev.cheminc.com/order-form/

    Please select: I have my Customer Code.

    Maybe it will make more sense.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  7. I understand exactly what you are trying to do. The gform_post_submission hook is what you would want to use to do it.

    You want to make the Product Name of the Product that appears in the Order Data use the Name the user enters in a text field. You have to do this when the form is submitted.

    There isn't currently an option to the let the user name the Product, so you'd have to have a Single Input field that asks them for the Product Name and then you'd use the gform_post_submission hook to update the name of the real Product Field so that it uses the value of the Single Input field.

    The gform_post_submission isn't for changing the value of a post, it's for manipulating the form data after it is submitted. Which is what you want to do, you want to manipulate the name of the product after the user submits it.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  8. brad13x
    Member

    Ok so now that I have the values where do I assign them? Can you clarify what the "real Product Field" is?

    "There isn't currently an option to the let the user name the Product, so you'd have to have a Single Input field that asks them for the Product Name and then you'd use the gform_post_submission hook to update the name of the real Product Field so that it uses the value of the Single Input field."

    So should I use a multi page form and update the "real Product Field" on the next form page or can I do it all in one page? Can it be done somehow with ajax so that once they enter the product name it updates the "real Product Field'?

    How I found the Keys and Values for those wondering.
    foreach($entry as $key => $value)
    $temp .= "Key: $key; Value: $value
    \n";

    Key: 16; Value: 1
    Key: 17; Value: product 1
    Key: 18; Value: 2
    Key: 19; Value: product 2
    Key: 20; Value: 3
    Key: 21; Value: product 3

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  9. You would have to have a Product field on your form that would be the real Product Field that will be updated with the user generated name.

    Then you'd have a standard single input field on your form for the user to enter the name of the Product.

    Then using the gform_post_submission hook when the form is submitted, not when they go to the next page of a multi-page form, but when the form is submitted on the final page of the form and the form is processed which is when the gform_post_submissino hook is triggered.

    Using the gform_post_submission hook and the Entry object you would get the value of the field you used for the user to enter the product name and UPDATE the name of the real Product Field with that value of the input field used to ask the user for the product field using the entry object.

    I'm not sure how else to explain it short of actually writing the customization.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  10. brad13x
    Member

    I understand what you are saying.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  11. brad13x
    Member

    Key: 23.1; Value: Product Name
    Key: 23.2; Value: $0.00
    Key: 23.3; Value: 1
    Key: 17; Value: Product Name 1

    How do I update the entry value? $entry['23.1'] = $entry['17']; ? That doesn't work.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  12. brad13x
    Member

    Also thanks for all your help so far Carl.

    Posted 12 years ago on Tuesday July 26, 2011 | Permalink
  13. Hi Brad13x,

    This thread sounds very similar to what you are trying to do:

    http://www.gravityhelp.com/forums/topic/customization-to-the-beginning-of-the-value-of-the-product-selected

    Posted 12 years ago on Wednesday July 27, 2011 | Permalink
  14. brad13x
    Member

    Awesome David. This is what I was looking for. Now is there a way to remove the values from the product fields (the product names I no longer need) so they don't show up in the email.

    What I have so far.

    add_filter("gform_product_info_1", "update_product_info", 10, 3);<br />
    function update_product_info($product_info, $form, $lead){</p>
    	//23:17 24:19 25:21 26:28 27:29
    	$product_info["products"][23]["name"] = rgpost('input_17');
    	$product_info["products"][24]["name"] = rgpost('input_19');
    	$product_info["products"][25]["name"] = rgpost('input_21');
    	$product_info["products"][26]["name"] = rgpost('input_28');
    	$product_info["products"][27]["name"] = rgpost('input_29');
        return $product_info;
    }
    Posted 12 years ago on Thursday July 28, 2011 | Permalink
  15. brad13x
    Member

    Any help?

    Posted 12 years ago on Wednesday August 3, 2011 | Permalink
  16. Hi Brad,

    Looks like the issue was with the source code I provided in the other thread. Instead of the using rgpost() to retrieve the value, you can get the value from the $lead variable instead. This means rgpost('input_17') would become $lead[17].

    Posted 12 years ago on Wednesday August 3, 2011 | Permalink
  17. brad13x
    Member

    Would changing the value of $lead[17] remove it from the invoice page?

    Here is an example of what I want and don't want. This is the email that gform sends after the form is submitted.

    http://imgur.com/WG0hH

    After I'm done with the user created product I no longer need it to appear above the Order section like it's doing now. It is redundant.

    How can I edit the values in $lead[17] so that they no longer show up on the purchase order? Once I'm done with the values in $lead[17] how can I clear them or remove them so they don't show up on the invoice.

    Posted 12 years ago on Thursday August 4, 2011 | Permalink
  18. Hi Brad,

    Assuming these unwanted fields are not product fields, the only way to remove them would be not user the {all_fields} token and create a custom email format for the notifications.

    Posted 12 years ago on Thursday August 4, 2011 | Permalink
  19. brad13x
    Member

    Thanks David. Did the trick. Any easy way to format it?

    Posted 12 years ago on Thursday August 4, 2011 | Permalink
  20. Unfortunately, there will be nothing as easy as the {all_fields} token for formatting. Anything else will have to be by hand or using an HTML editor and pasting the code in.

    Posted 12 years ago on Friday August 5, 2011 | Permalink

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