Is it possible to have an email auto-generated when an order is paid?

Our system currently allows customers to order and choose manual payment. Once the order is received and confirmed, we then allow them to pay for their order by visiting the /order/order_hash page.

Because the order was already received, it's not firing to a "new" status and we don't receive an email on payment.

Is there a way to send an email to user and admin when the order changes from "unpaid" to "paid"?

2 Answers 2


I can't say for sure if Espresso Store is supposed to do that anyways, or if there is supposed to be a simple setting for it, but almost certainly one of these hooks:


Could be used. I don't have that addon (I'm in education, not retail) anywhere so I'm not sure, but one of those hooks should work to grab a change in that status. Example extension method:

function detect_email($order)
    // get the current order status (i don't actually know the tables/columns...)
    $prev_order = ee()->db->select('status')
                          ->where('order_id', $order['order_id'])

    // compare for fun!
    if ( $order['status'] != $prev_order['status'] &&
         $order['status'] == 'paid' ) {

        // yay! we went from something else to paid!
        // use the email class to fire off some goodness
        $email_msg = "WORD SAUCE PAID DING DING : " . $order['order_id'];

        ee()->email->wordwrap = true;
        ee()->email->mailtype = "html";
        ee()->email->from("[email protected]");
        ee()->email->subject("Successful pay.");

You can setup as many order statuses as you need by going to Store > Settings > Order Status and create as many additional status that you would like. Then in Store > Settings > Email Templates you can create additional statuses for each email template you would like to be sent out.

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.