Webform supports embedding hidden fields within a form that get submitted whenever the webform is submitted. My idea is to add the ability to include a product like this as well: the user never has to select the product itself, but instead is directed to the checkout when the form is submitted anyway.

Comments

karing’s picture

Hi - You can do this with some very simple jQuery. I use it to on e.g. ticket orders for school musical - the 'would you like to make it a dinner theater? Is a very simple yes/no radio button -> if 'yes' -> I add x number of dinner tickets with jQuery (where x is what they had already selected for show tickets). To do this you make the commerce fields in webform -> then in jQuery: hide these fields -> then populate their value with x.

karing’s picture

Here's a code snippet:

...
$num_tickets_adults = $("#edit-submitted-tickets-number-of-tickets-adults").val();
$num_tickets_students = $("#edit-submitted-tickets-number-of-tickets-students").val();

if($("#edit-submitted-tickets-dinner-theatre-confirm-1").is(':checked')) {
        $total_tickets = parseInt($num_tickets_adults) + parseInt($num_tickets_students);
        $("#edit-submitted-tickets-saturday-march-14-7pm-saturday-march-14-7pm-dinner-189").val($total_tickets);
      }
...
Marelmel’s picture

Thank you for your attention.

I am going to try it.

Best.

johnennew’s picture

Status: Active » Fixed

Going to close this ticket.

johnennew’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.