Hook and send Woocommerce data after click Place Order button

For this three possibilities:

If you really want to do it on order place you would have to use the hook:

woocommerce_new_order

However I would recommend you use the hook:

woocommerce_order_status_completed

This would make sure that the order is finished when you send then information.

To catch the information before billing you could always use:

woocommerce_before_checkout_billing_form

If this still isn’t working you could check the hook list:

https://docs.woocommerce.com/wc-apidocs/hook-docs.html

You then would simply have something like:

add_action( 'woocommerce_order_status_completed', 'wc_send_order_to_mypage' );
function wc_send_order_to_mypage( $order_id ) {
$shipping_add = [
            "firstname" => $order->shipping_first_name,
            "lastname" => $order->shipping_last_name,
            "address1" => $order->shipping_address_1,
            "address2" => $order->shipping_address_2,
            "city" => $order->shipping_city,
            "zipcode" => $order->shipping_postcode,
            "phone" => $order->shipping_phone,
            "state_name" => $order->shipping_state,
            "country" => $order->shipping_country
        ];
//from $order you can get all the item information etc 
//above is just a simple example how it works
//your code to send data
}

Since the ultimate goal is to have your own payment system I would recommend you check out this tutorial that explains how to integrate your own payment gateway

https://www.skyverge.com/blog/how-to-create-a-simple-woocommerce-payment-gateway/

Leave a Comment