I live and work in Japan. We have a small oyster company with limited resources and I am doing all the programming myself, but I have limited knowledge and skill. First time posting, sorry if this isn't a good question or I make a mistake...Thanks in advance.
I am using the latest Woocommerce 3.2.3. I also use a few plugins, including an email control one, a custom email for thanking a and confirming bank (furikomi) payments, and the WooCommerce for Japan plugin.
I want to create a workflow that it similar to other popular Japanese EC sites (rakuten karamishop, yahoo!auctions, etc) . There is no auto-completing in Japan, it's so service focused it's crazy, everything must be meticulously checked and confirmed. In case you're curious, the Japanese standard flow is: Customer Makes Order -> Customer gets blanket confirmation e-mail -> We check to make sure the fees are correct and the order is something we can fill and process -> We send a processing order with a specific date and time for delivery, etc. -> We pack and fill the order and then send a "shipped" message with the tracking code.
ANYWAY I found this:
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
global $woocommerce;
if ( !$order_id )
return;
$order = new WC_Order( $order_id );
$order->update_status( 'on-hold' );
}
from here. And many variations along this theme. This gets me half way there. But the e-mails are still triggering processing (for PayPal and COD, anyway).
I'm also aware that the email for COD orders seems to be hooked here:
add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'change_payment_complete_order_status' ), 10, 3 );
in the "class-wc-gateway-cod.php" file. And that these triggers will result in the e-mail that I don't want, the "processing" e-mail.
// Triggers for this email
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
Right now we have three payment methods: Paypal, Furikomi (bank transfer for Japan), and COD. I want all of these payment methods to return with the on-hold message, which we will use as the "auto-confirm" message. The status of them in the system should also be "on-hold". Then we can move them to processing and we can handle everything smoothly after that.
So, in summation, I guess need to: 1. Unhook all order statuses from all gateways. 2. Have all completed new orders defaults to "on-hold" 3. This should make it so the "on-hold" e-mail triggers, killing two birds with one stone.
I seem to have only managed to change the status from whatever it was AFTER the order processing and triggers have completed to "on-hold" (same as the official plugin it seems), which only helps us on the back end.
SIDE note: They really should just include this in the free Woocommerce for Japan plugin if they really want Woocommerce to compete here, but that community is slow and when I asked a question they just offered for me to pay for a custom plugin.
Thank you!
EDIT I figured it out! I just found this page, with unhook codes for emails. Unhooked and rehooked with this new email trigger. Here's the code in case anyone needs it:
/**
* All orders that would normally go from pending to processing go from pending to on-hold
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_onhold_order' );
function custom_woocommerce_auto_onhold_order( $order_id ) {
global $woocommerce;
if ( !$order_id )
return;
$order = new WC_Order( $order_id );
$order->update_status( 'on-hold' ); //All new orders go to "on-hold"
}
add_action( 'woocommerce_email', 'unhook_new_order_processing_emails' );
function unhook_new_order_processing_emails( $email_class ) {
// Turn off pending to processing for now
remove_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_Processing_Order'], 'trigger' ) );
// Turn it back on but send the on-hold email
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $email_class->emails['WC_Email_Customer_On_Hold_Order'], 'trigger' ) );
}