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.

Sending product value instead of label to paypal

  1. Mike
    Member

    I'm using a product field type: radio buttons with images instead of radio buttons, so I have html in my label field. I've also filled out the "value" section with the real name, so for example:

    Label = <div class="product1" title="Product 1">Product 1</div>
    Value = Product 1
    Price = $50

    However, when it sends to Paypal, the HTML shows up in the description area (on the payment page) instead of the value. How can I have GF send the value to Paypal to use as a description, instead of the label?

    Posted 11 years ago on Tuesday September 11, 2012 | Permalink
  2. You can use the gform_paypal_query filter to modify the data which is being sent to PayPal:

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

    I'm not sure if there is an easier way to do it or not.

    Posted 11 years ago on Wednesday September 12, 2012 | Permalink
  3. Mike
    Member

    Could you give me an example of what code to use to send value instead of label for a product?

    Posted 11 years ago on Wednesday September 12, 2012 | Permalink
  4. Hi, Mike,

    I have responded to your Priority Support request, but I am including the info here as well. Take a look at the example here http://pastie.org/4740851 which will strip out the html so you can use the filter mentioned by Chris.

    Posted 11 years ago on Monday September 17, 2012 | Permalink
  5. Can i get a bit more instructions on this? I can get it to work. I have the same request. I need to have PP to use the "VALUE" instead of "LABEL".

    I pasted Dana code in the function and it still does not work.

    Posted 11 years ago on Thursday September 20, 2012 | Permalink
  6. Here is another approach that can be used: http://pastie.org/4762039 .

    Posted 11 years ago on Thursday September 20, 2012 | Permalink
  7. i still can not get this to work. http://nfa.mozaicltd.com/donate/
    The LABEL get pass through and not the actual value.

    Posted 11 years ago on Thursday September 20, 2012 | Permalink
  8. this is what i added to the function.php. 10 is the form ID field.

    add_filter('gform_paypal_query', 'update_paypal_query', 10, 3);
    function update_paypal_query($query_string, $form, $entry){
    	parse_str($query_string, $qs_param); //put PayPal querystring into an array
    	if (is_array($qs_param)){
    		$field = RGFormsModel::get_field($form, 10); //get form field, the 2nd parameter is the field id
    		$value = RGFormsModel::get_lead_field_value($entry,$field); //get the value of the field
    		//product fields are pipe-delimited, the value will be the first item in the string
    		if (!empty($value)){
    			$ary_values = explode("|",$value); //put the values into an array and grab out the first item [0]
    			$qs_param["item_name_1"] = $ary_values[0]; //replace the item name in the querystring with the value, the "1" is the field id
    			$query_string = "&" . http_build_query($qs_param); //put array back into querystring form
    		}
    	}
    
    	return $query_string;
    }
    Posted 11 years ago on Thursday September 20, 2012 | Permalink