How to add and edit custom order status in woocommerce

Add and modify custom order status in woocommerce? This is useful for a clearer description of the customer’s order status. By default, WordPress and woocommerce cannot add custom order status. However, with the help of the code, you can add it to the online store and edit it immediately. However, before starting the process, let’s take a look at why woocommerce needs to add or edit custom order status. Why add and modify custom order status in woocommerce? The use of appropriate order status is very important to ensure the procurement process of all online stores. E-commerce websites have several stages that require customers to complete the purchase. Of course, these additional steps will reduce revenue.
Or, the fewer order statuses that need to be processed, the higher the sales rate of the e-commerce store. You can also more easily manage the entire website. However, in all cases, at least two types of order status are required. When the user successfully orders, the first type of order status is required. It can be set as pending payment, pending processing or pending processing. Similarly, another order status is required, similar to the order completed. Here, the customer may have settled and received the goods. However, if the order is not completed due to unavoidable reasons, it may be regarded as failure, cancellation or refund.
Therefore, woocommerce has the following default order status: Failed processing while waiting for payment completely shelves cancelled refunds. These order statuses are ideal for all e-commerce websites. This far exceeds the usability of ordinary websites. However, if these default states are still not enough, you must create several custom states for the online store. After being added to the website, customers can more clearly understand the status of woocommerce orders. For example, to specifically inform the customer that the order is waiting in the order status, you must add a custom woocomer order status.
How to create a woocommerce custom order status? Woocommerce orders are considered special types of customized articles. Therefore, the post_status value will be appended to the wp_posts table of the database in the same way as other post types. Therefore, to include custom order status in the available status list, you must use the register_post_status() WP built-in function. However, before continuing, make sure you make these changes programmatically or using one of the subtheme plug-ins to create a subtheme. In this way, when the WordPress theme is updated, the customization of the theme file will not change. Similarly, if you accidentally make unnecessary changes, we will remind you to back up the WordPress website in order to restore the website.
1. functions. Accessing the PHP file woocomerce must access the theme feature file before creating and editing custom order status. First, on the word press dashboard, navigate to shapes > theme file editor. Then select the \
\/\/Register new status
Function register_wait_call_order_status(){
Register_post_status(
\
\
‘sh
Ow_in_admin_status_list \
\
\
\
) );
}
\/\/Add custom status to order status list
Function add_wait_call_to_order_statuses ($order_statuses){
$new_order_statusess = array ();
foreach ( $order_statuss as $key => $status ) {
$new_order_status[ $key ] = $status;
if ( ‘wc-on-hold’ === $key ) {
$new_order_statuses [\
}
}
Return $new_order_statuses;
}
Add_action (\
add_filter( ‘wc_order_statuses’, ‘add_wait_call_to_order_statuses’ );
Several hooks are used here. The first is wp_init (), which is used to register the new state. After registering the status, this function is no longer needed. When finished, you can delete this hook and its function callbacks.
The second is the wc_order_states() filter hook, which includes the new order status in the available list. Therefore, you can attach to the order on the woocommerce manager dashboard. You can view the status of a new custom order when you edit the order in the WordPress dashboard’s woocommerce > order. Then click the status option, and the \
The following example code edits two order statistics: \
foreach ( $order_statuss as $key => $status ) {
if ( ‘wc-processing’ === $key ) {
$order_statuses [\
}
If (\
$order_statuses [\
}
}
Return $order_status.
}
add_filter( ‘wc_order_status’, ‘QuadLayers_rename_status’ ); After adding code, don’t forget to update the file.
That’s all! This is how to edit the status of an existing or custom order on the woocommerce website. Male woocomerce once again declares to delete the order status, but wc_order_statuses() is useful for deleting a specific order status. In this case, the \
if( isset( $statuses[‘wc-refunded’] ) ){
unset( $statuses[‘wc-refunded’] );
}
Returns the $status.
}
add_filter( ‘wc_order_statuss’, ‘QuadLayers_remove_stat

Author:

Leave a Reply

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