Hi @james400studio
Please use below code snippet in theme function.php file to set order status to completed.
add_action('woo_wallet_payment_processed', 'woo_wallet_payment_processed_callback');
if(!function_exists('woo_wallet_payment_processed_callback')){
function woo_wallet_payment_processed_callback($order_id){
$order = wc_get_order($order_id);
$order->set_status('completed');
$order->save();
}
}
hey @subratamal ,
Appreicate your help but this code is not working. I pasted this code in my theme’s function.php file, but the order status is still getting set to “processing”.
Please check if you have placed the code in the active theme function.php file because we have checked this code in our local environment and it is working for me.
Thank you.
@subratamal
Hey,
Found the issue. Actually it marks order “completed’ when the order payment is done via woo wallet.
I actually need to mark the “wallet recharge order” as “completed” and not the orders paid through wallet.
Sorry for the confusion.
@subratamal Update : sorry, I need to change the status to “wallet-recharge” of wallet top up order. I have already created custom “wallet-recharge” status. I tried this below code, but the wallet top is not showing in the wallet. So I guess it first needs to be marked as completed and then changed to “wallet-recharge”. Your help would be appreciated.
Here’s the code I tried –
add_filter('woocommerce_payment_complete_order_status', 'woocommerce_payment_complete_order_status_callback', 10, 3);
if (!function_exists('woocommerce_payment_complete_order_status_callback')) {
function woocommerce_payment_complete_order_status_callback($status, $order_id, $order) {
if (is_wallet_rechargeable_order($order)) {
$status = 'wallet-recharge';
}
return $status;
}
}
Use bellow code instead.
add_action('woo_wallet_credit_purchase_completed', 'woo_wallet_credit_purchase_completed_callback', 10, 2);
if(!function_exists('woo_wallet_credit_purchase_completed_callback')){
function woo_wallet_credit_purchase_completed_callback($transaction_id, $order){
$order->set_status('wallet-recharge');
$order->save();
}
}