2

We're working on our first Craft Commerce site and are in need of your good advice. This might be related to a similar question (Craft Commerce: send notification emails when setting status dynamically?) but I can't comment there.

We have a Craft Commerce setup with two payment gateways for credit card and bank transfer (Manual payment). We'd like to achieve the following scenario: 1) If the customer pays with Credit Card, the order status is "Approved". They receive an email with the invoice and confirmation. 2) If the customer pays via bank transfer, the order status is "Pending" and they receive a different email.

We can't find any clues on the docs on how to pass a specific status on checkout. Is there anything obvious we might be missing? I appreciate any input. Thanks!

2 Answers 2

6

Listen for the onBeforeOrderComplete event and do something like this (replacing values to match your setup).

craft()->on('commerce_orders.onBeforeOrderComplete', function($event){
    $order = $event->params['order'];
    if ($order->paymentMethodId == 2)
    {
        $order->orderStatusId = 3;
    }
});
2

You probably need a small plugin listening for commerce_orders.onOrderComplete which checks the payment method and re-saves the order with the required status.

1
  • We're on it, but we're having a hard time finding the handle for the payment method and detailed documentation on the order model. Can you point me in the right direction to find this?
    – Farmer1
    Commented Apr 25, 2017 at 16:18

Your Answer

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

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