• Resolved Alain Aubry

    (@caban13)


    Hi

    [WooCommerce PayPal Payments]

    Whenever a payment is completed the order is automatically the WC status is set to “complete”, provided the order is virtual.

    I figure that this a feature, you are assuming the order is going to automatically completed by the system, this is not my use case, I sell digital products that have to “delivered”, like a virtual meeting that is going a happen in a few days or an online course that needs to start at a certain date.

    At this moment, I am changing the WC status manually in ALL this cases, my ideal status o “processing”.

    Do ypu have a setting or a filter that allows this?

    Thank you so much

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Krystian

    (@inpsydekrystian)

    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

    Thread Starter Alain Aubry

    (@caban13)

    Thank you so much!

    I will test it deeply

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.