• Resolved Heikki

    (@heikkiwaan)


    Hello.
    I have this line of code in my plugin:
    add_action( ‘woocommerce_order_status_completed’, ‘hh_function_name_removed’, 10, 1 );

    and a function
    hh_function_name_removed($order_id)
    {
    $logfile = “/home/myname/test.log”;
    file_put_contents($logfile, date(“r”).”\n”, FILE_APPEND);
    return;
    }

    But the function seems to be never run.

    I have tried “woocommerce_order_status_completed” and “woocommerce_payment_complete” with no success.

    Any ideas on how to get a code run after a completed order in woocommerce?
    Thanks.

    edit: Oh and i mean when the customer goes back from the payment gateway to the woocommerce site, then should the plugin code be run.

    • This topic was modified 7 years, 5 months ago by Heikki.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there!

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Slack Community for development assistance: https://woocommerce.com/community-slack/

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @heikkiwaan The hook woocommerce_payment_complete runs after a payment is complete. Your edit stated you wanted to have the function run when the customer returns from the gateway, correct? The order can be placed in Processing status if items in the order need to be shipped, so going off of just the completed status will not work in this instance. woocommerce_payment_complete fires off when the payment is complete.

    This action can be seen here:
    https://github.com/woocommerce/woocommerce/blob/3.5.2/includes/class-wc-order.php#L121

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Well don’t close, because I am interested in the same thing!

    I need to receive the woocommerce_order_status_completed message while not interfering with the standard woocommerce payment processing. I need to update another plugin’s database based on payment completion.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘woocommerce_order_status_completed never called’ is closed to new replies.