You can do something like this
public function getStuffDone() {
$order_ids = array( 358,368 );
$items = array(); // contains the names
foreach ( $order_ids as $order_id ) {
$order = wc_get_order( $order_id );
foreach ( $order->get_items() as $item_values ) {
$items[ $order_id ][] = $item_values->get_name(); // add the name to the array
}
}
return $items; // array containing all the names
}
Related Posts:
- Show modified time if post is actually modified
- AJAX handler throws 400 (Bad request) – why?
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Most elegant way to enqueue scripts in function.php with foreach loop
- WordPress – thumbnail image from youtube (function and loop)
- Adding WooCommerce to a Custom Theme – not working [closed]
- A snippet after every image
- Function to show only first instance of shortcode
- Automatically insert php function into post $the_content
- Creating loop within functions.php
- Display WooCommerce subscriptions for user [closed]
- How to use max and min values of custom fields
- Custom Shortcode, functions PHP WP_Query loop
- Filtering posts by category name based on page’s slug
- 2 Loops, Only Displaying 1 Loop in Both Loops
- Having a Function Inside of the Loop
- Getting different functions data while using while loop in wordpress
- Create a new query in function.php to filter blog posts
- Limit length of first excerpt in the loop
- Default Custom Field Value Automatically Update
- Multiple Loops Meta Data
- Why doesn’t is_page(id) work in functions.php?
- The Loop not looping?
- While loop with an exception after a count is reached
- How do I pull excerpts from pages?
- Output loop to function return?
- issue with if/elseif in_array inside foreach loop display only one post
- Genesis Framework: How to exclude a specific author from archive custom loop
- Problem with calling custom function in a foreach loop
- Get term slug by term id and then explode it
- Using functions.php to include code that’s processed inline
- Breaking up multiple words and inserting an image after first word
- Simplest Way to Build Custom Archives Page?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- the_date() and the_time() functions display actual date an time instead of published date and time
- How set a while with a function
- Pass post ID from archive template to functions file
- Prevent function from triggering on current page
- How to use `foreach()` in ajax call
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Only seems to be displaying one child when there are supposed to be multiple
- Integrate WP Tiles into existing loop (index.php) and theme
- Check if excerpt is empty at loop-portfolio
- Function to get the name in database table from the comma separated string
- Way of getting queried loop before the query with a filter hook?
- Post variables not displaying correctly in custom function
- Why don’t some template tags work when querying information on single.php?
- Parse error: syntax error, unexpected ‘endforeach’ (T_ENDFOREACH) in [closed]
- How do grab the main loop, with conditions, and output via shortcodes
- Creating mixture of shortcodes to use in the visual/text editor
- Get full slug for a WordPress Post
- Update post meta with wp cron
- Functions.php code that only runs on localhost?
- hook a functions to change wp-config from functions.php
- Check if the user has explicitly set an excerpt
- Slugs as breadcrumbs for Pages
- Shortcode with custom content attribute?
- Add a Post Thumbnail to an RSS Feed with custom size
- Automatically add author’s name to post_tag
- Print Dashboard menu name and link
- Develop function get_template_part in functions.php
- Change comment_reply_link URL
- Ajaxing function in widget class
- wp_register_script(… $in_footer = true) not working
- Restore Image Title Text
- Output and filter data from a XML url
- How do I create a function that simulate the click on Update button for all posts?
- Full page template function
- Redirect from “private” page and functions.php which tag add to add_action()?
- WordPress listen to $_POST in functions.php
- Add Element as a Filter to the_content
- Can’t properly set the_title add_filter to show short_URL
- WordPress function, Run using Crontab
- Check if the image size is available and if not use ‘full’ image size
- Tags break custom Excerpt function
- Can set_post_thumbnail be used to remove a thumbnail?
- Get post format
- Fail to get the total number of posts
- Call two different function.js depending on page
- Display a random tag but using cron to control frequency of change
- resizing of thumbnails not working
- How Do I include/Import a Custom Widget from the Parent theme into My Child Theme?
- Need To Resize Images Exactly Without Losing Image Details
- Can’t load assets
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- Warning and fatal error
- Including admin-options.php file in Child Themes
- Adding an IF ELSE to a function
- wordpress ajax is not working for dropdown selection
- Providing fallback function and allow override by plugin
- is_page_template wont allow me to enqueue scripts
- Updating site content after an AJAX call without a page reload
- need help with ‘… read more’ excerpt in functions.php
- jQuery HoverIntent is not a function
- Use $_POST[‘value’] inside functions.php
- get_footer can’t find any variables set in functions.php
- Sessions in word press [duplicate]
- Options.php loop won’t show!
- “woocommerce_output_related_products” not working
- WordPress – Notice: Function wp_enqueue_script was called incorrectly