Get amount of a coupon in gform_pre_submission [RESOLVED]


i have a GF with :

  • Options
  • Coupon (Limited to 1)
  • Redirect to Stripe

Before to go to Stripe, i need to get datas to send to an API.
So i use the action gform_pre_submission_ID()
And then i do this :

add_action('gform_pre_submission_10', 'custom_function', 10, 2);
function custom_function($form)
    $code = rgpost( 'input_19' );
    $couponJson = rgpost( 'gf_coupons_10' );
    $coupon = json_decode($couponJson);

    $data = array(); //$data to send
        $data["code_coupon"] = NULL;
        $data["valeur_coupon"] = NULL;
        $data["code_coupon"] = $code;
        if($coupon->$code->type == "percentage"){
            $data["valeur_coupon"] = $coupon->$code->amount; //Problem here !
            $data["valeur_coupon"] = $coupon->$code->amount;

My problem is in case of percentage coupon, i can’t get the real amount of the coupon, i just get the percentage (15% for exemple).

Is there a way to do this ? Everything i find is post_submission with the $entry.


In this code, can you take the coupon code and calculate the amount of the applied coupon by multiplying the percentage by the form total, or whatever the coupon is being applied to? You should have all that in rgpost.

Hi chris,

Thanks, finally i did this yes.

1 Like