• Resolved Design Extreme

    (@designextreme)


    I would like the user to select from a few pre-assigned amounts and a custom amount as a donation form.

    Form with multiple amounts

    I just want to use Stripe; not PayPal.

    Is it possible to set the amount in the form (e.g. a pre-assigned input) or as a data option or something else?

    Thank you,

    Noah

Viewing 1 replies (of 1 total)
  • Thread Starter Design Extreme

    (@designextreme)

    Actually, I did it myself with an Ajax call to this PHP function I wrote…

    function set_donation_amount()
    {
    	$ret = array(
    		'success' => FALSE
    	);
    	
    	$type = (isset($_POST['type']) && is_string($_POST['type'])) ? preg_replace('/[^\w_-]/', '', strtolower($_POST['type'])) : '';
    	$donation_form_id = (isset($_POST['form_id']) && is_numeric($_POST['form_id'])) ? intval($_POST['form_id']) : 0;
    	$amount = (isset($_POST['amount']) && is_numeric($_POST['amount'])) ? floatval($_POST['amount']) : 0;
    	
    	switch($type)
    	{
    	case 'amount':
    		update_post_meta($donation_form_id, '_cf7pp_price', $amount);
    		$ret = array('success' => ($amount > 0), 'amount' => $amount);
    		break;
    	}
    	
    	echo json_encode($ret, TRUE);
    	die();
    }

    It calls the function just before plugin requests the same amount/price information. It does the job unless two people submit at the same time.

    Is there a better way, such as one of the methods in the first post?

Viewing 1 replies (of 1 total)
  • The topic ‘Donations Form with Multiple Amount Options’ is closed to new replies.