1

I am developing a site which has "normal" shop stuff that is added to cart and bought through the checkout process. But it also has to support submitting requests for food catering jobs. This is a slightly different workflow. I want to do this by creating a "catering product", which has a number of line items which represent the food items the customer wants supplied on the day.

So I can setup a custom product page with all the line item fields etc on it. But now I am wanting to combine "add to cart then complete checkout without payment" into one action, so that this all happens in one go when they submit the catering request form. (The client will then get in touch with the customer, confirm the catering job details, then the customer will pay for the job once everyone is happy.) So really I need to combine two actions - "update cart" and "complete cart".

Any suggestions on the best way to do this? Do I have to write my own module? Any advice/tips greatly appreciated!

1 Answer 1

3

There's a few moving parts here but Commerce 3.3, which was recently released, just introduced support for partial or deferred payments which should help get this done easily.

I'm not sure what your checkout looks like but one way to handle it would be to post via ajax. Basically anything that updates on-the-fly (addresses, line items, etc.) needs to to get pushed to update-cart first. You don't really need to write a plugin for this.

Then when you ready to complete the order, you could also make one final push to update cart. Then when a user wants to finalize, they then hit the commerce/cart/complete endpoint.

You could also have a separate "confirm your order" screen which could give the user time to check over their catering before it gets sent.

Either way, you want to have the new allowCheckoutWithoutPayment setting set to true.

It's also possible to grab a partial payment (say if your client wants to do a deposit).

2
  • 1
    Just saw your answer now. I ended up doing what I needed via two sequential ajax calls, commerce/cart/update-cart followed by commerce/cart/complete and it all works perfectly. So you had definitely flagged the right approach. Cheers for taking the time. May 1, 2021 at 3:33
  • @bhuBouevidya do you have any example code on your solution?
    – Tad Ward
    Dec 22, 2021 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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