WooCommerce: Managing Initial Order Status

envelopes, letters, wooden stamp, stamp, mail, post office, envelopes, stamp, stamp, stamp, stamp, stamp, mail

In a recent Business Bloomer Club Slack thread, a member asked for help with setting the initial order status in WooCommerce based on specific cart conditions.

The challenge was that there are no payments involved in this store, so they had removed the payment methods using the following code:

add_filter( 'woocommerce_cart_needs_payment', '__return_false' );

The goal was to set the order status to “Processing” under certain conditions and to “RFQ” (Request for Quote) under others. Since there were no payments, the user needed to find the appropriate hook or filter to manage the initial status before any order events occurred.

Triggering Order Status Change

Initially, it was suggested that the status change could be triggered on the “Thank You” page, but that approach was deemed too late, as all actions related to the “Processing” status would already have been carried out.

Using the Correct Hook

Rodolfo shared a more appropriate hook to handle the change in order status earlier in the process:

apply_filters( 'woocommerce_payment_complete_order_status', $this->needs_processing() ? 'processing' : 'completed', $this->get_id(), $this );

This hook allows for conditional logic based on the order’s data. The filter checks whether the order needs processing and sets the status accordingly. By using this hook, the member could change the order status to “RFQ” or any other status required before the processing status actions took place.

A Working Solution

While the woocommerce_payment_complete_order_status filter didn’t work for this specific case, the member found a solution using another method from Business Bloomer’s resources: Automatically Completing Processing Orders.

This alternative approach helped the user achieve their goal of managing the order status based on custom conditions.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

Your email address will not be published. Required fields are marked *