Title: Extract order elements into array
Last modified: September 28, 2022

---

# Extract order elements into array

 *  Resolved [clickingclients](https://wordpress.org/support/users/clickingclients/)
 * (@clickingclients)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/extract-order-elements-into-array/)
 * How can I extract details from an order into an array, while on the “Order Edit”
   page and then loop through them?
    e.g.
 * $order = wc_get_order( $order_id );
    $items = $order->get_items(); $items_array
   = array(); foreach ( $items as $item ) { $items_array[0] = $item->get_name();
   $items_array[1] = $item->get_product_id(); $items_array[2] = $item->get_variation_id();}…
 * Then I want to be able to sort them on $items_array[0] and print them out with
   an echo.
 * My array structure isn’t correct as it’ll keep getting overwritten.
 * How to achieve the correct array structure to input them and extract?

Viewing 1 replies (of 1 total)

 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/extract-order-elements-into-array/#post-16053795)
 * Hi [@clickingclients](https://wordpress.org/support/users/clickingclients/)
 * I understand that you need help with programmatically extracting details from
   an order into an array.
 * Kindly be informed that support for custom coding is beyond the [scope of support](https://woocommerce.com/support-policy/)
   we are able to provide in this forum. This particular forum is for questions 
   that are related to the WooCommerce core features.
 * For help with custom coding we recommend [the WooCommerce Developer Resources Portal](https://developer.woocommerce.com/).
 * You can also visit the [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
   We’re lucky to have a great community of open-source developers for WooCommerce,
   and many of our developers hang out there, as well.
 * Lastly, for direct assistance with code customizations, we recommend consulting
   with the WooCommerce Customizations Partners. [https://woocommerce.com/customizations/](https://woocommerce.com/customizations/)
 * Nevertheless, this thread is open for a bit to see if anyone is able to chime
   in to help you out here.

Viewing 1 replies (of 1 total)

The topic ‘Extract order elements into array’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 2 participants
 * Last reply from: [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/extract-order-elements-into-array/#post-16053795)
 * Status: resolved