Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

WebPro Care Latest Articles

Change WooCommerce Payment Status for Prepaid Orders

WooCommerce order status management is an essential store operation that could take up a lot of your time. It is important that all the orders are regularly updated to reflect the most recent status.

Cash-on-Delivery is a very popular payment option that no WooCommerce store owner could overlook. However, there are scenarios where customers pre-pay for their purchases to speed up the fulfillment process. In such cases, there is a chance that even when the order has been fulfilled (dispatched and delivered to the customer), you might miss updating the order status.

Here’s a Simple WooCommerce Payment Status Solution

You can automate the process of updating the order status for orders that are pre-paid. The order gets updated to “Complete” automatically as soon as the WooCommerce payment status gets updated.

add_action('woocommerce_order_status_changed', 'woocommerce_payment_complete_order_status',10,3);

function woocommerce_payment_complete_order_status($order_id)


if ( ! $order_id ) {



 $order = wc_get_order( $order_id );

if ($order->data['status'] == 'wc-processing') {


if ($payment_method != "cod")


 $order->update_status( 'wc-completed' );




How It Works

The code snippet uses the woocommerce_order_status_changed hook to call in the function when the order status gets changed. Once verifying that the order status is “Processing”, and the payment method IS NOT Cash-on-Delivery, the order status is changed to ‘Complete”

update_status() sets the order status that is passed to the method. Here is a brief list of the order status you can pass to this method:

<option value=”wc-pending”>Pending payment</option>

<option value=”wc-processing”>Processing</option>

<option value=”wc-on-hold”>On hold</option>

<option value=”wc-completed”>Completed</option>

<option value=”wc-cancelled”>Cancelled</option>

<option value=”wc-refunded”>Refunded</option>

<option value=”wc-failed”>Failed</option>

wc_get_order() is a wrapper function to get the order object that provides all data about a specific order.

Similarly, $order gets the order information as an object through wc_get_order() function. You can also use the following lines in the above code to get the order total in formatted format.


$order->get_formatted_order_total( );

At the checkout page, if you have selected “Cash on delivery” payment method as shown below:

After processing the order, you might see:

 WooCommerce Order Product Information

The following code snippet displays the products in an order. Note that this code snippet is to be placed at the location in the template file where you wish to display the information:

$filters = array(

'post_status' => 'any',

'post_type' => 'shop_order',

'orderby' => 'modified',

'order' => 'ASC'


$loop = new WP_Query($filters);

while ($loop->have_posts()) {


$order = new WC_Order($loop->post->ID);

foreach ($order->get_items() as $key => $lineItem) {

echo '<br>' . 'Product Name : ' . $lineItem['name'];

echo 'Product ID : ' . $lineItem['product_id'];

if ($lineItem['variation_id']) {

echo 'Product Type : Variable Product';

} else {

echo 'Product Type : Simple Product';





Changing WooCommerce order status, particularly for the pre-paid orders is a simple matter of adding a simple code snippet to the WooCommerce template files. If you need help with implementing the idea, do leave a comment and I will get back to you.

Related Posts

Leave a comment