How to set orders to automatically complete when payment is sucessful?

This topic has 2 replies, 2 voices, and was last updated 17 minutes ago ago by Luca Rossi

  • Avatar: Woolwolf
    Woolwolf
    Participant
    November 20, 2024 at 12:13

    I have noticed that WooCommerce by default, sets the order status to “processing” when an order is placed. However, since I only sell downloadable products, I am concerned that my customers may be confused by receiving an email stating that their order is being processed, especially when the same email also includes their download link. Is there a way to automatically set these orders to “completed” as soon as the payment is received?

    Best regards,
    Trine

    Content is visible for topic creator and
    support staff only.
    Files is visible for topic creator and
    support staff only.
    1 Answer
    Avatar: Justin
    Luca Rossi
    Support staff
    November 20, 2024 at 14:20

    Dear @Woolwolf,

    We hope this message finds you well.

    To address your request, please try adding the following custom code to the functions.php file located in your child theme:

    
    add_action( 'woocommerce_payment_complete', 'wpdesk_set_completed_for_paid_orders' );
    function wpdesk_set_completed_for_paid_orders( $order_id ) {
        $order = wc_get_order( $order_id );
        $order->update_status( 'completed' );
    }
    

    For further details and guidance, you may refer to this article: [WooCommerce Payment Complete Hook](https://wpdesk.net/blog/woocommerce_payment_complete-hook/).

    Should you have any questions or need additional assistance, please feel free to reach out.

    Best regards,
    The 8Theme Team.

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.