Email triggers
-
Hello,
I hoping you can assist as i have a couple workflow changes and hope it work with email designer plugin.
Here is the process:
1. Customer places order, they are only give payment method of “Order”. (i am using Invoice Gateway For WooCommerce plugin to register order without payment) – Order status goes to “processing” and New Order email is triggered to Admin and Customer.2. Site owner logs in, puts order On-Hold while they edit inventory counts, add shipping costs, recalculates. On-Hold email is triggered to Customer.
3. Site owner changes status to “Payment Pending” in order to get customer to pay now. Site owner also has to manually select “email invoice order details to customer”. Invoice email is triggered to Customer to pay.
4. Customer logs in to pay. We have Elavon Converge payment gateway for Credit Card processing setup. Payment is successful. We have code so that it auto changes order status to Complete when payment type is Credit Card.
– The order status goes from “Pending” to “completed”. Complete email is triggered to CustomerPROBLEM AND QUESTIONS
It also triggers “New Order” email again to customer and Admin. I assume because the code sates to change status to “complete” that maybe for a split second it goes to “processing”. Is there a way to put a code in so that emails are NOT triggered if payment type is “Credit Card”.
Also, The “Customer Complete” notification, can that also be sent to Admin email? This way site owner can know that payment was successful as there is no email notification of this that i can see.
Here is code i am using for restricting payment gateway at checkout:
add_filter( 'woocommerce_available_payment_gateways', 'my_switch_gateways_by_context'); add_action( 'woocommerce_order_status_processing_to_on-hold', 'enable_processing_to_on_hold_notification', 10, 2 ); function enable_processing_to_on_hold_notification( $order_id, $order ){ // Getting all WC_emails array objects $mailer = WC()->mailer()->get_emails(); // Send the "On Hold" notification $mailer['WC_Email_Customer_On_Hold_Order']->trigger( $order_id ); } function my_switch_gateways_by_context($available_gateways) { global $woocommerce; $endpoint = $woocommerce->query->get_current_endpoint(); if ($endpoint == 'order-pay') { unset($available_gateways['igfw_invoice_gateway']); } else { unset($available_gateways['elavon_converge_credit_card']); } return $available_gateways; }
Here is code i am using to change status to “completed”
// Update order status based on the id of payment gateway function credit_card_complete_order_status( $order_id ) { $order = new WC_Order( $order_id ); if ( $order->payment_method == 'elavon_converge_credit_card' ) { $order->update_status('completed', 'Automatically Completed'); } } add_action( 'woocommerce_payment_complete', 'credit_card_complete_order_status' );
- The topic ‘Email triggers’ is closed to new replies.