Accept both WooCommerce and Direct Checkout on the same form

With the introduction of eForm v4.6, it is now possible to conditionally accept both WooCommerce and Direct Checkout in the same form. Click here to view a demo. Visit this link to download the form.

The trick is to provide a WooCommerce product id conditionally and for the same logic, hide the payment element. Let’s walk through it.

#1: Form Setup

First setup your product price calculation as usual. In the sample form, we have a simple radio element to select from available products and one math element to show the price.

The only thing required here is an element to put conditional logic against. We have added a radio element with two options.

  • Add to cart.
  • Quick checkout.

We want to use WooCommerce when user selects Add to cart and just show the eForm payment field when user selects Quick checkout.

So we note down the element id, which in our case is M1.

#2: Enable WooCommerce and eForm Payment

First enable WooCommerce and put math element id. Do not put any product id in the main product id field.

We will put product id (in our case 1002) in the conditional product selector. We put the condition against element M1 has value which equals to add to cart.

Now eForm will only activate WooCommerce when the condition is met. Internally it works like this.

  1. eForm resolves WooCommerce product id from your base and conditional definition.
  2. eForm checks if the product id is not empty and the product exists.
  3. If it exists, then activate WooCommerce checkout.
  4. Otherwise, don’t activate WooCommerce.

#3: Enable General Payment

Now enable eForm payment options and add a payment element. We need to add similar logic to the payment element, but for the opposite condition.

So we put logic M1 has value which equals to quick checkout.

Now eForm will only activate general payment if the condition is met.

So what we did here is, create two mutually exclusive conditions. For one condition, we activate WooCommerce and for the other we activate eForm Payment.

If you have any question, feel free to ask through support forum.

Swashata has written 257 articles

Hi there, I am the Lead Developer at WPQuark.com. I love to create something beautiful for WordPress and here I write about how to use them. When I am not working, usually I am doing a number of other creative things ;).