• Right now, I have a function that updates some information about our sale in our database and is currently hooking in to ‘woocommerce_order_items_table’, because I need access to the Order object, but since this is fired every time the page loads, if the user refreshes or navigates to the order confirmation screen, it creates a duplicate call to our database.

    I tried to find a hook on the documentation, but the hooks don’t mention what actually fires them, or what arguments get passed to the hooked function.

    I need a hook that satisfies the following criteria:

    1. The function is fired when the user completes a purchase.
    2. The function is fired only once per order.
    3. The Order object is passed to the function.

    https://wordpress.org/plugins/woocommerce/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,
    Suggest you search the woocoomerce plugin for the ‘woocommerce_checkout_order_processed’ hook. This may be what you need.

    Thread Starter digiholic

    (@digiholic)

    It looks like that one gives order_id. Is there a way to get that into the actual order object?

    Suggest:
    (1) take a look at the ‘woocommerce_checkout_order_processed’ hook’s passed 2nd argument
    (2) take a look around in the code in that file where the hook is found for another hook….

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

The topic ‘What hook should I use here?’ is closed to new replies.