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: dynamically change the price of a Pricing Option field

  1. Hi,
    I am building a form using Gravity Forms and Woocommerce, for customers to place a custom product order. They should be able to select the number (in this case, number of days' worth of juice), and then choose certain addons. The price should update dynamically at the bottom, so the number of days part (and thus total price) is easily shown with an Option Pricing field, Drop Down type. Label "1 day", Price "$10.00"; Label "2 days", Price "$20.00", and so on.

    Here's the kicker: the other addons should dynamically change how much more expensive they become based on the number of days. For instance, say I have a Low Sugar option (still an Option Pricing field, Checkbox type). $2 extra. That's easy enough, but if I selected "2 days" earlier, that should change and it should now say $4 extra. Or I selected "30 days" and now it should say $60 extra.

    Is there a way to simply make the Price of a choice display the result of a formula? In this example, it'd be (2 * number of days). I'm stumped on how to make this happen.

    Posted 6 years ago on Monday June 10, 2013 | Permalink
  2. David Peralty
    Administrator

    Can you link to your form? Are you using the latest versions of WordPress and Gravity Forms?

    We have two types of fields Products and Options, and options are attached to products, and the Quantity multiplies it all.

    So if a product is worth $5, and an option is $2 and it is selected, then the total is $7, and if they want two, it would be $14. I just tested this on my test site, and it worked as expected.

    Posted 6 years ago on Friday June 14, 2013 | Permalink
  3. Hi David, thanks very much for the helpful reply. You caused me to reexamine my process, and it seems that my problem was with the Quantity field. It was not achieving the goal (of updating the price when a new quantity was entered). My Product field on the form was set at $0.00, while the correct product price was set in WooCommerce. I reversed this and set the WooCommerce product price to $0, and put the price into the Product field. Voila - now it shows as $0 when the quantity field is empty, and updates dynamically as the quantity is increased, and my options work as desired too. Thank you!

    Posted 6 years ago on Friday June 14, 2013 | Permalink
  4. David Peralty
    Administrator

    Glad to hear it. I haven't used WooCommerce yet, so I had to approach it form Gravity Forms only. Thanks for providing feedback so I'll know what to look for in the future.

    Posted 6 years ago on Friday June 14, 2013 | Permalink
  5. Hey David,

    I'm hoping you can help me with one more thing. So we got this all sorted and now when I change the quantity, any additional options increase the price by their amount multiplied by the product quantity. Perfect.

    BUT - what if I want an option to add on something that increases the price by a fixed amount no matter what the quantity? Is that possible?

    Thanks!

    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  6. David Peralty
    Administrator

    You wouldn't use an option, but instead a new Product field. Options are always tied to products and influenced by their quantity.

    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  7. Hmm, I'm slightly confused as to how that would work. When I add another product field it seems to change the price of the whole product the form is associated with. Are you suggesting there is a way to use this field to tack on a single extra product to the purchase?

    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  8. Well, now I see how that works with a text box for quantity, or a drop-down even... is there a way of making the new product field a checkbox?

    Posted 6 years ago on Thursday June 20, 2013 | Permalink
  9. David Peralty
    Administrator

    Nope, only options allow the checkbox type. You could make a product that is $0 and then add an option tied to that product that is a checkbox system.

    Posted 6 years ago on Thursday June 20, 2013 | Permalink