Answer the question
In order to leave comments, you need to log in
Code to automatically convert the status "pending payment" to the status "completed" for an order in a store on the woocomerce platform?
hello, can you please help
, it is necessary that when the status of the order is "pending payment" the system itself transfers it to the status "completed"
I insert this code into functions.php
function wc_mark_all_orders_as_complete( $order_status, $order_id ) {
$order = wc_get_order( $order_id );
if ( $order_status == 'processing' && in_array( $order->get_status(), array( 'on-hold', 'pending', 'failed' ) ) ) {
return 'completed';
}
return $order_status;
}
add_filter( 'woocommerce_payment_complete_order_status', 'wc_mark_all_orders_as_complete', 10, 2 );
Answer the question
In order to leave comments, you need to log in
I don't know where you got your code from, but it's fundamentally wrong.
function wc_mark_all_orders_as_complete( $order_id ) {
$order = wc_get_order( $order_id );
$order->payment_complete();
}
add_action( 'woocommerce_order_status_pending', 'wc_mark_all_orders_as_complete' );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question