woocommerce_new_order

woocommerce_new_order

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: woocommerce.9.7.1

do_action('woocommerce_new_order') is found 4 times:

  • /includes/data-stores/class-wc-order-data-store-cpt.php line 113
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
        if ( in_array( $order->get_status( 'edit' ), array( OrderStatus::AUTO_DRAFT, OrderStatus::DRAFT, 'checkout-draft' ), true ) ) {
            return;
        }
     
        do_action( 'woocommerce_new_order', $order->get_id(), $order );
    }
     
    /**
     * Read order data. Can be overridden by child classes to load other props.
     *
     * @param WC_Order $order Order object.
  • /includes/data-stores/class-wc-order-data-store-cpt.php line 229
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
            $current_status !== $previous_status
            && ! in_array( $current_status, $draft_statuses, true )
            && in_array( $previous_status, $draft_statuses, true )
        ) {
            do_action( 'woocommerce_new_order', $order->get_id(), $order );  // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
            return;
        }
     
        do_action( 'woocommerce_update_order', $order->get_id(), $order );  // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
    }
  • /src/Internal/DataStores/Orders/OrdersTableDataStore.php line 2744
    2740
    2741
    2742
    2743
    2744
    2745
    2746
    2747
    2748
    2749
    2750
         *
         * @param int       Order ID.
         * @param \WC_Order Order object.
         */
        do_action( 'woocommerce_new_order', $order->get_id(), $order );
    }
     
    /**
     * Helper method responsible for persisting new data to order table.
     *
     * This should not contain and specific meta or actions, so that it can be used other order types safely.
  • /src/Internal/DataStores/Orders/OrdersTableDataStore.php line 2838
    2834
    2835
    2836
    2837
    2838
    2839
    2840
    2841
    2842
    2843
    2844
        && $changes['status'] !== $previous_status
        && ! in_array( $changes['status'], $draft_statuses, true )
        && in_array( $previous_status, $draft_statuses, true )
    ) {
        do_action( 'woocommerce_new_order', $order->get_id(), $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
        return;
    }
     
    // For backwards compat with CPT, trashing/untrashing and changing previously datastore-level props does not trigger the update hook.
    if ( ( ! empty( $changes['status'] ) && in_array( 'trash', array( $changes['status'], $previous_status ), true ) )
        || ( ! empty( $changes ) && ! array_diff_key( $changes, array_flip( $this->get_post_data_store_for_backfill()->get_internal_data_store_key_getters() ) ) ) ) {

See this hook used in plugins: