Change the WooCommerce payment status for prepaid orders - Managing the WooCommerce order status is an essential activity in a store that takes up a lot of time. It is important that the entire order is updated regularly to reflect the most recent status.
Cash-on-Delivery is a very popular payment option that no WooCommerce website owner can ignore. However, there is a scenario where customers prepay for purchases to speed up the execution process. In such a case, it is likely that even if the order has been fulfilled (sent, delivered to the customer), you miss the order status update.
This is a simple WooCommerce payment status solution
You automate the process of updating order statuses for prepaid orders. The order will automatically update to Complete when the WooCommerce payment status is updated.
How it works
The code uses the WooCommerce_order_status_changed hook to call the function when the order status changes. Once the order status is verified as Processing, the payment method is NOT cash on delivery, the order status is changed to ‘Completed.
See more: Who has viewed my facebook
update_status () sets the order status passed to the method. Here is a brief list of the order status you can switch to this method:
wc_get_order () is a wrapper function that retrieves order objects that provide all data about a specific order.
Similarly, $ order retrieves order information as an object via the wc_get_order () function. You also use the following line in the above code snippet to get the total order number in the format.
At the checkout page, if you have selected the cash payment method on delivery as shown below:
Once the order has been processed, you see:
Product information ordering WooCommerce
The following code snippet will display products in order. Note that this code will be placed at the location in the sample file where you want to display information:
Changing the status of a WooCommerce order, especially for prepaid orders, is a simple matter when adding a simple snippet of code to the WooCommerce sample file. If you need help implementing an idea, leave a comment, I'll get back to you.