Woocommerce Retrieving custom field value from orders
I am trying to get a specific meta value from all of a customer's orders and simply echo them to the Downloads page within My Account. This is what I have so far, but unable to get $skey to retrieve and display the assigned values that are set from the backend. Basic idea is to go to a customer's order, define what we need for said order in the s_key custom field and just have that populate for customers just after their download links purchased.
Any help on this would be awesome! Certified php beginner so its possible I am doing something not quite right.
function return_s_key_field() {
$args = array(
'customer_id' = $user_id);
$orders = wc_get_orders($args);
$skey = get_post_meta( $orders, 's_key', true );
echo ('div id="request_title"/div');
if ( empty($skey) == 'true' || $skey != 'N/A' ){
echo ('div id="key_container"div id="key_label"pArbitrary text:/p/divdiv id="steam_key"p' . $skey . '/p/div/div');
}
else {
echo ('div id="key_container"div id="key_label"pArbitrary text:/p/divdiv id="steam_key"pN/A/p/div/div');
}
}
add_action( 'woocommerce_after_available_downloads', 'return_s_key_field' );
Topic woocommerce-offtopic account custom-field Wordpress
Category Web