Set a Minimum Price on a Quotation Form

Hey,
I need help getting a form to work correctly. The form is to quote customers who want their windows cleaned, however because it’s typically low value, my client wants a minimum price adding to the quote. I’ve been following this tutorial which seems to work on the front-end but doesn’t work when sending the quote and only sends the email with the product totals. Here’s what I mean:

By default, the total products = £6.00

So the minimum fee applies to make it £12.00

But when the quote is emailed to both admin and the user it shows £6.00

Here’s the link to the extra screenshots.

Anyone know how I can get the email to show the exact same as the front end? The code I’ve used is below:

<script type="text/javascript">
    gform.addFilter( 'gform_product_total', function(total, formId){
        //only apply logic to form ID 3
        if(formId != 3)
            return total;
        if(total < 12)
            total = 12;
        return total;
    } );</script>

and in the functions.php

/** 
 * GRAVITY FORMS
 */
add_filter( 'gform_product_info', 'add_fee', 10, 3 );
function add_fee( $product_info, $form, $lead ) {
	$minimumprice = 12;
	$currentprice = $product_info['products'][1]['price'];
	$currentprice = str_replace('$','',$currentprice);
	$additionalfee = $minimumprice - $currentprice;
	if ( $currentprice >= 12 ) {
		$product_info = array(
            'products' => array(
                array(
                    'name'     => 'Minimum Order Amount',
                    'price'    => 12,
                    'quantity' => 1,
                ),
            ),
        );
	}
    return $product_info;
}

Others may be able to help you debug the code, but to quickly fix this, I think I’d remove the the snippet, and just use a Calculation product field.

In a number field that you hide with CSS (“gf_hidden” in the custom CSS so that it still is available on the page programatically), add together the totals of all the product fields with their merge tags.

Add the Calculation field, and set it’s conditional logic to hide if the total is more than 12.

Then, set up the calculation so that the price of the field is 12 minus the total of all of the other products. This allows the person filling out the form to see that there is a minimum fee so that they’re not surprised by that.

Might that work?

Thanks Bet and you may be on to something with the merge tags however the client doesn’t want to show any prices or the minimum fee, so on the styled version of the form all prices are hidden with css, so the only section that shows prices is the total.

Would there be a way to hide it?

Kind regards

Jason

You can hide any field with the custom CSS class “gf_hidden” in the custom CSS. Does that help?

Hi Jason, not sure about the tutorial, but this should be possible by using Gravity Forms Conditional Pricing | Gravity Perks | Gravity Wiz and creating a condition where the Product will have a minimum price if some conditions are met (the Quantity, for example)

I hope this helps!

Thanks Dario but trying to avoid a premium plugin for a one off project. The client won’t pay the yearly costs.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.