I'm building a site that is driven by Craft Commerce but does not take payment online. Rather, the customer adds what they need to a cart and submits to the company for a quote.

I need to build a contact form that allows the customer to submit their name, email, phone, and company name. When submitted, the form should also turn the cart into an order. I've tried setting 'isCompleted' to 'true' and setting the 'dateOrdered' but cannot seem to get the cart to transition into an order.

Below is the code I've been testing to try to get the cart to convert into an order. I feel like I'm missing something obvious. Any advice is appreciated.

<form method="POST">
    <input type="hidden" name="action" value="commerce/cart/updateCart">
    <input type="hidden" name="isCompleted" value="1">
    <input type="hidden" name="dateOrdered" value="{{ now.format('Y-m-d H:i:s')}}">
    {{ getCsrfInput() }}

    <input type="submit" value="Submit">

Edit: Here's the working code as suggested below, where "2" is the ID of the manual payment method I created.

<form method="POST">
    <input type="hidden" name="action" value="commerce/payments/pay">
    <input type="hidden" name="paymentMethodId" value="2">
    {{ getCsrfInput() }}

    <input type="submit" value="Submit">

I don't think you can do it like that - in Commerce, the order gets completed when a payment is made.

Fortunately, you can use the manual payment mechanism, which automatically completes the order, as the fake 'payment' type to get this to occur. Just go in to Commerce settings and create a new payment type of 'manual' set to 'authorize only', and give it a name like 'Get Quote'.

To actually complete the order, you'll need to post the manual paymentMethodId to a call to commerce/payments/pay. If you're doing this in a contact form, you'll have to intercept the form submit and post this via AJAX I guess.

Alternatively you could write your own controller to complete the order with some plugin code, but the above solution is essentially built in an intended for this sort of thing.

  • Full success. I set up a Manual payment method and added its ID as a hidden field. Then just changed the action as you suggested. I don't think I'll need a contact form, since I think I can just customize this form as it is. – Matt Everson May 10 '17 at 14:05

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.