0

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"?

0

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:

https://www.exp-resso.com/docs/extension_hooks.html#transaction_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')
                          ->from('expresso_orders')
                          ->where('order_id', $order['order_id'])
                          ->get()->row_array();

    // 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()->load->library('email');
        ee()->email->wordwrap = true;
        ee()->email->mailtype = "html";
        ee()->email->from("specialty@twinkies.com");
        ee()->email->to($order['contact_email']);
        ee()->email->subject("Successful pay.");
        ee()->email->message(entities_to_ascii($email_msg));
        ee()->email->message($email_msg);
        ee()->email->Send();
    }
}
| improve this answer | |
0

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.

| improve this answer | |

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.