Some basic issues with code. Since this hook do not have any data supplied to function, you need to get current user logged in.
Secondly, as already mentioned by @antti, get_post_meta accepts first parameter as post id (in this case order id), single value.
function return_s_key_field() {
$orders = wc_get_orders(array(
'customer_id' => get_current_user_id(),
'return' => 'ids',
))
$meta_data = array();
foreach ($orders as $order_id) {
$meta_data[$order_id] = get_post_meta($order_id, 's_key', true);
}
// var_dump($meta_data);
}
add_action( 'woocommerce_after_available_downloads', 'return_s_key_field' );
Try un-commenting var_dump and then use that data however it is required.
Related Posts:
- How to access custom order item meta data from a meta key in WooCommerce?
- Save Custom Fields for Variations Product
- Adding existing user custom field value to a woocommerce product [closed]
- Adding Custom Text Area to WooCommerce Product
- WooCommerce conditional required checkout fields [closed]
- Include woocommerce custom field value in front-end search result
- woocommerce product custom field
- How to get customfield value by woocommerce product ID
- Conditionally hide or show woocommerce product variation in fontend by custom field
- Woocommerce: Custom fields and email shortcodes, ec_custom_field
- Bulk remove post meta
- How to create html block to display extra information on woocommerce single product page
- Display WP-Types custom fields in post [closed]
- Modifying custom order item meta from admin order view
- How to create a dropdown select of all items in an ACF field group
- How do I add an image upload, custom field to a WooCommerce product?
- WooCommerce – Adding Custom Fields To Invoice
- Woocommerce Product Custom Select List (not variation)
- jQuery – Automatic event trigger does not **really** check my form
- How to add new field to the account address?
- How to display custom field in woocommerce email orders? [closed]
- Update custom field values on edit address page woocommerce
- Woocommerce frontend edit custom fields
- Is it possible to add Term Meta Fields to a WooCommerce Attribute?
- Why does my numeric meta query work only on one meta key and not the other?
- Update custom field on the fly
- (woocommerce) How to get product id form order id & then retrieve custom meta linked to product?
- How to delete WooCommerce Products than have a specific custom field?
- WooCommerce 3 get custom variation on process order [closed]
- How to save array option as text and not integer?
- Use a different catalog image than the featured image
- Check if value exists before saving
- Add Custom field under the post title [closed]
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- price calculation from custom field (woocommerce) [closed]
- Hiding custom fields when content is empty [closed]
- Cannot save values to custom fields for variations on Woocommerce 2.4.6
- Send checkout page custom field in order email
- Extract array from custom field
- Assign class to Drop Down Selections in WooCommerce Products Custom Fields
- ORDER BY custom field value
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Create a select drop down of available menus
- Adding a prefix to a post title
- copy attachments to another post type and change attachment url
- Cannot edit post meta fields with rest API
- Only display custom field if it there is a value inside
- Slow meta query with multi meta keys
- Custom Field Multiple Clauses
- Custom field values repeating
- Send Multiple Custom Field Values Through the URL
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Separate table or usermeta
- Woocommerce with metabox plugin
- using multiple meta_key and meta_value in query_posts
- global function to apply filter to custom field
- How to add a new meta key and assign timestamp to posts
- Strange issue saving custom field data for a WooCommerce order
- Print custom field in Query Loop block
- Is there a simpler version of WP Media?
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- Alter main archive, to show posts with meta as last
- Add microdata from schema.org [closed]
- Displaying multiple URLs as custom field values
- Collect user custom field in product page woocommerce
- How can I save custom meta to one global value?
- get posts where a custom field contains a text
- Displaying a custom field
- How to use media upload on metabox post page without breaking TinyMCE?
- Branch made by several custom values
- How can php be used to return data from custom fields in a post?
- Get meta field value of all catgories
- Change Page Order by Custom Field (Magic Fields)
- Filter post style attribute
- Update some (not all) post titles with custom field values before running the Loop
- data-value for custom woocommerce field showing in code but not visable on page load
- Arrays in custom fields or is there a better way?
- Use value from ACF to populate other fields
- Setting user permissions per post
- Problem Advanced Custom Fields PRO
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Weird custom fields data lost
- Custom product page’s style for printing
- query_posts -> get page_id from custom field
- Output Custom Field value to shortcode
- Update custom table on metabox POST
- display custom media folders to wordpress media popup
- Should I store arrays in custom fields or create custom tables?
- Problem saving meta data
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- WP_query returns error when used for custom widget
- Get custom field from other post in carousel
- Form fields based on custom fields
- Create citation and url in post using 3 custom fields with conditions for each field… So close!
- How can I attach files without using a plugin?
- Show only first image of multiple image field
- Change Fields of Comments and make them searchable?