2

I run Craft Commerce and want people to get certain items for free, but still pass them through Commerce order system (in order to collect the emails and also perform some automation)

So basically they enter code and get 100% discount.

Now, if the person has ONLY free item in their cart, I don't want to ask them for credit card data or send to payment gateway. I want to just authorize the 'payment' of $0.00

I know I could use some template logic and use Manual or Dummy gateway, but I'm afraid some people will try to fool the system, so I want to make sure the 'free' gateway only works if order total is zero.

Does anyone know some plugin / custom gateway that I could use here?

2 Answers 2

4

Since it looks like the solution does not exist yet, I ended up creating custom plugin/gateway.

Works same as Manual gateway with the only difference that it only approves free purchases.

https://github.com/intoeetive/freecheckout

1
  • Manual gateway has a 'allow for free orders only' setting that can be used. Dec 13, 2021 at 13:19
2

The "Free order payment strategy" config setting is used when submitting to the commerce/payments/pay form action.

Submitting to this form action with the setting set to "Free orders complete immediately", will skip calling the gateway and just complete the free order without making a transaction.

You would still need to make sure that the form submitted to the controller action is still valid for the gateway used, so most developers force the use of the "Manual" payment gateway for free orders, so that no form data would need to be collected. The manual payment gateway has a gateway setting to only allow free orders. This might not be ideal though so there is another option.

Another way to do it would be to run Commerce 3.3 or greater and use the commerce/cart/complete form action, that will complete the order immediately without needing a payment form submitted.

This form action only works if you turn the allowCheckoutWithoutPayment config setting to true. The only issue with this is that with this turned on customers could submit to this form controller action for orders that still have an amount outstanding (non free orders). This lets the customer complete the order, and pay later. This might take a change to your customers’ backed order processing, email confirmations, payment reminders etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.