对于这三种可能性:
如果您真的想按订单进行,则必须使用挂钩:
woocommerce_new_order
但是,我建议您使用挂钩:
woocommerce_order_status_completed
这将确保在您发送then信息时完成订单。
要在计费前捕获信息,您可以始终使用:
woocommerce_before_checkout_billing_form
如果这仍然不起作用,您可以查看挂钩列表:
https://docs.woocommerce.com/wc-apidocs/hook-docs.html
然后,您只需执行以下操作:
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
}
由于最终目标是拥有自己的支付系统,我建议您查看本教程,该教程解释了如何集成自己的支付网关
https://www.skyverge.com/blog/how-to-create-a-simple-woocommerce-payment-gateway/