Find Jobs
Hire Freelancers

Woocommerce and php guru to help create array from woocommerce order object to be used to connect to external api

$10-30 USD

Completed
Posted over 2 years ago

$10-30 USD

Paid on delivery
All the woocommerce item meta is already done and being added to the order via checkout. // Get order item meta. $order = wc_get_order( $order_id ); // Get transaction id. $transaction = $order->get_transaction_id(); // Get more order meta values // Get via loop order item meta foreach ( $order->get_items() as $itemId => $item ) { // Product id. $productId = $item->get_product_id(); // Product quantity. $productQt = $item->get_quantity(); // with product id connect to api to get api product data. I have this working and I get 1 array json_encoded [{"Product":"api_id","value1":"1","value2":"2","quantity":"0"}] $apiproduct = $api_result; $apiproduct_decoded = json_decode( $apiproduct, true ); $remove_first_array = $apiproduct_decoded[0]; $product_Value1 = $is_product_controller[0]['value1']; $product_Value2 = $is_product_controller[0]['value2']; // Now I need to multiply array value 1 and value 2 by the woocommerce product quantity. These values are going to be used later to connect to api and send data. $sum_value1 = $product_Value1 * $productQt; $sum_value2 = $product_Value2 * $productQt; // Now I need to rebuild original api result array with woocommerce quantity $remove_first_array_change = array_replace($remove_first_array, ['Quantity' => $productQt]); $rebuild_api_array = $remove_first_array_change; // Get gift, returns true or false $gift = wc_get_order_item_meta( $itemId, '_resource', gift ); // Get resource id from woocommerce. With the resource id $resource = wc_get_order_item_meta( $itemId, '_resource', true ); } All of the above is done and working. I need help with the last part. To connect to the external api I need to make a loop one per unique woocommerce item meta $resource with a constructed body. If I have 3 woocommerce products with the same $resource I need to combine all values. Maybe do this outside the final foreach? foreach ( $resource as $uniqueresource ) { // There's another value that comes from the external api the $resource_data. We need to get this value to include in the body for the last call and is based on the unique $resource. // Since the loop is based on unique $resource I only need to get this value once per different $resource.... We are looping the $resource. // I already have this call working. $body = array( 'resource_data' => $resource_data, 'products' => array($rebuild_api_array, $rebuild_api_array, $rebuild_api_array,etc), like this [{"Product":"123","value1":"1","value2":"0","quantity":"7"},{"Product":"456","value1":"2","value2":"1","quantity":"2"},{"Product":"999","value1":"1","value2":"4","quantity":"6"} etc. last array can not have ending seperator coma or api returns error] 'sum_value1' => should be the sum of all $sum_value1, 'sum_value2' => should be the sum of all $sum_value2, 'gift' => if 1 resource $gift returns true then this setting is immediately true for all identical $resource, ); // connect to api via POST }
Project ID: 31746738

About the project

13 proposals
Remote project
Active 2 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hi I can format your data to match the API request data. I CAN START RIGHT NOW. Kindly contact me via chat to get started,. Looking forward to work on this. Thank you so much
$30 USD in 1 day
5.0 (55 reviews)
5.6
5.6
13 freelancers are bidding on average $25 USD for this job
User Avatar
I checked the requirements . I just want to discuss few more things. I am available to discuss now. Waiting for your response. Thanks.
$50 USD in 1 day
4.9 (52 reviews)
6.1
6.1
User Avatar
I have some questions regarding the specifications of the project. Could we please have a chat? My Skills: WooCommerce, PHP and WordPress
$10 USD in 7 days
4.7 (92 reviews)
6.4
6.4
User Avatar
Hi there, I am an experienced WordPress Designer/Developer with more than 8 years of experience. I will develop a fully functional Website with a sleek and minimal design to your specifications, WordPress WooCommerce WordPress E-Commerce WordPress Speed-Optimization WordPress Theme Customization WordPress Plugin Customization Thanks and regards, Komal,
$10 USD in 3 days
5.0 (1 review)
3.1
3.1
User Avatar
Hello, We have reviewed the code structure and can easily help you to connect it to external API and will make a loop one per unique woo commerce item meta. Kindly grant us the access to the store so we can start working and complete the task ASAP. Waiting for your positive response! Thanks,
$30 USD in 2 days
5.0 (2 reviews)
0.9
0.9
User Avatar
Hello I have read your request thoroughly & i can surely work on your project. However I have few questions to ask, are you available for a quick discussion? Regards
$20 USD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
*Web Developer and WordPress Expert* Hi there I have 6+ years of experience in Web Development Including PHP and HTML. Please provide some information about your requirements so that I can understand your needs and start working together on completing your task soon. Utilize my skills by hiring me. Contact me for further discussion. Thank you Pargat
$40 USD in 7 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of PORTUGAL
Estoril, Portugal
5.0
1
Payment method verified
Member since Apr 20, 2012

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.