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.

Woocommerce Formula Minimum Price

  1. Hi. I have developed a form for a product (Woocommerce plugin) that calculates the price based on a height and width entry. All works beautifully but I need it to have a minimum order of £50. The square meetre price is £175.00 but if someone says, enters 2cm x 10 cm, it comes out way under the £50 minimum. I know we can't use and/if/else statements in the formula box and I have tried 100s of different ways to basically say - if total is less than £50 - make it up to £50! I have tried to use the conditional options but this just hides the field from visual, not from the calculation - any help greatly appreciated as I have now been working on this one thing for three days! Many thanks guys

    Posted 7 years ago on Tuesday July 10, 2012 | Permalink
  2. David Peralty
    Administrator

    You could create your own validation:
    http://www.gravityhelp.com/documentation/page/Gform_field_validation

    Then if the user submits it, it'll come back with an error and say something like "Minimum order $50."

    Posted 7 years ago on Tuesday July 10, 2012 | Permalink
  3. Hi David, many thanks, the only problem is I don't want to force anyone to buy more - just pay a minimum of £50. So for instance, if the choose dimensions of 20cm x 20cm that is fine and would cost say £25 in the shop. However, due to production costs, delivery, etc, a minimum spend must be made of £50. To do this in validation terms, they would need to say, buy a 40cm x 40cm piece of metal to get above £50 but they don't want that size. So effectivelly, we need a bit of code that says if order total is less than £50, round it up to £50. Does that make sense and does it sound possible? Apologies, I'm not a PHP expert!!

    Posted 7 years ago on Tuesday July 10, 2012 | Permalink
  4. David Peralty
    Administrator

    Okay... I'm going to have to give it some thought. Can you give me more information on how you expect it to work? If they select a cost less than $50, then what should happen? Should they receive a message? I'm trying to figure out how this will work and still make sense to users.

    Posted 7 years ago on Tuesday July 10, 2012 | Permalink
  5. Hi, many thanks for looking into. Basically, I guess the only way to do it is that the minimum price for the custom size option is always £50, if the custom sizes selected cost more then it just adds the extra onto the £50. So if I select 5cm x 10cm, the calculation makes it £1.75 but this needs to be £50, etc. Here is one of the products: http://www.thesplashbackfactory.com/splashback-products/designer-steel-splashback-pinstriped-finish.

    Hope this makes sense. Many many thanks

    Posted 7 years ago on Monday July 30, 2012 | Permalink
  6. You'll see on the above page when someone selects 'custom size', they can have any size they want but the calculation will set the price under £50 if they select a smaller size and it must be and show a minimum of £50. The other set sizes need nbo interference as they are all above £50 anyway. Many thanks

    Posted 7 years ago on Monday July 30, 2012 | Permalink
  7. David Peralty
    Administrator

    I just don't know if Gravity Forms can do that and maintain the ability to calculate values above that level. There isn't any conditional logic in calculations so it is not like we can go:

    if price < $50 then price = $50, else do calculation as normal.

    I'm sorry to say, but you've hit on a limitation of Gravity Forms that I don't know how to get around.

    Posted 7 years ago on Monday July 30, 2012 | Permalink
  8. Hi David,

    many thanks - I thought that was the case - tried for about 10 hours on the form to find a solution! It basically needs some sort of 'if' statement as you say. Many thanks - we'll have to think of another route!

    Posted 7 years ago on Monday July 30, 2012 | Permalink
  9. David Peralty
    Administrator

    Wish I had a better answer for you. I'll let the development team know another person is looking for conditional logic in calculations. Maybe it will get bumped up in our development plan. All my best!

    Posted 7 years ago on Monday July 30, 2012 | Permalink
  10. Hi, as you were so quick to respond, I thought I would drop you another quick question, is there a way to pass an entered user value from a field into an html field? Basically, when the user enters the height and width in the relevent fields, I want to use these values to change the dimensions of an image within the form, to show a quick graphical representation of their selection, i.e.

    <img src="http://www.thesplashbackfactory.com/wp-content/uploads/2012/06/AAF-Splashback-Black-Gloss-Splashback-Full-No-Handle-200x200.jpg" width="VALUE FROM FORM FIELD 1" height="VALUE FROM FORM FIELD 2">

    Many thanks

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  11. You would have to do this with jQuery on the current page, as Gravity Forms does not know about the value that was entered in the form until the form is submitted. You would capture the value from those fields, then modify the HTML attributes for the image tag. It's a customization beyond the support we can provide here. You may want to look into the jQuery attr method:

    http://api.jquery.com/attr/

    Setting several attributes at once

    To change the alt attribute and add the title attribute at the same time, pass both sets of names and values into the method at once using a map (JavaScript object literal). Each key-value pair in the map adds or modifies an attribute:

    $('#greatphoto').attr({
    alt: 'Beijing Brush Seller',
    title: 'photo by Kelly Clark'
    });

    When setting multiple attributes, the quotes around attribute names are optional.

    You should give your img tag a class or ID so you can properly target it.

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  12. David Peralty
    Administrator

    To pass it live as users select it, you would have to use JavaScript, and I'm not an expert in that, and can't be of much use there. You could have a DIV in an HTML block that expands to reveal different images based on what a user selects, but I don't have the expertise to code that. You'll want to find someone specialized in JavaScript/JQuery to do that.

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  13. Hi Chris, many thanks. I'm afriad I'm struggling a little - I have tried for hours - have I got the syntax wrong or is still because the jquery will not update when the form fields are entered as it needs a keydown or something? Sorry for being a pain - I have tried for 5 straight hours to do this - I'm just not a coder I'm afriad! Many thanks.

    <img id="splashimage" src="http://www.thesplashbackfactory.com/wp-content/uploads/2012/06/AAF-Splashback-Black-Gloss-Splashback-Full-No-Handle-200x200.jpg" />
    <script>
    $('#splashimage')
    .attr('width', '#input_9_2');
    $('#splashimage')
    .attr('height', '#input_9_3');
    </script>

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  14. Hi David, many thanks - just seen your response as I posted mine! I think you are right - I need someone with a far better knowledge than me to sort this! Thanks again.

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  15. PS Chris - it works fine when I change the attr values to fixed values, i.e. 200, 500, etc but I can't seem to pull the two gravity form field values when entered: #input_9_2, #input_9_3. Thanks

    Posted 7 years ago on Tuesday July 31, 2012 | Permalink
  16. I see you created a new topic for this latest issue. I'll close this one and we will continue the discussion there:

    http://www.gravityhelp.com/forums/topic/change-image-size-live-when-form-field-entered

    Posted 7 years ago on Wednesday August 1, 2012 | Permalink

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