Ecommerce Shopify WordPress Discussion

Create array of woocommerce order product ID & Qty (to send woocommerce order information to an external api)

I am trying to send woocommerce order information to an external api. I am using the following function: add_action( 'woocommerce_new_order', 'send_order_to_api', 10, 2 ); function send_order_to_api( $order_id, $order ){ // api code here } The API wants to receive my data in the following format: $incoming_order = [ 'spot_id' => 1, 'phone' => '+0000000000', 'products' => [ [ 'product_id' => 1, 'count' => 9 ], ], ]; I know I need to get my woocommerce product information like this for example: $order->get_items(); and I know I need to turn it into a loop like this: $order_items = $order->get_items(); foreach( $order_items as $product ) { } But this is where I am stuck
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.