Hello @caban13
Thank you for reaching out.
This behavior is part of the default WooCommerce workflow. WooCommerce automatically sets the order status to “Complete” for virtual products once the payment is completed, assuming the products are delivered automatically. This functionality is unrelated to how the PayPal Payments plugin operates, as all payment plugins follow the same standard.
You can use the following snippet to override the default workflow. The snippet changes the order status to “Processing” instead of “Complete” for virtual products:
add_filter('woocommerce_payment_complete_order_status', 'custom_virtual_order_status_updated', 10, 2);
function custom_virtual_order_status_updated($status, $order_id) {
$order = wc_get_order($order_id); // Retrieve the order object
if ($order) {
$all_virtual = true; // Assume all items are virtual initially
foreach ($order->get_items() as $item) {
$product = $item->get_product(); // Get the product from the item
if ($product && !$product->is_virtual()) {
$all_virtual = false; // If any product is not virtual, set to false
break;
}
}
if ($all_virtual) {
// Change status to "processing" for virtual products
return 'processing';
}
}
return $status; // Keep the default for other types of orders
}
This snippet works on our end, but we strongly recommend testing it thoroughly in a staging environment with multiple scenarios before implementing it on a live site. You can use a plugin like Code Snippets to safely add this code to your site. Alternatively, you may want to explore custom plugins that allow you to override WooCommerce order statuses based on your specific requirements.
If you need further assistance or clarification, feel free to reach out.
Kind Regards,
Krystian