• Resolved clickingclients

    (@clickingclients)


    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)
Viewing 1 replies (of 1 total)
  • The topic ‘Extract order elements into array’ is closed to new replies.