0

How can I check if my order item has a specific meta data key when getting the order item values using $order-> get_items()

Currently to get an order item value I would do this:

$product_name = $item_data['name'];

I have a meta key called Address Line 1 however this is only present on some order items. I need to check if an order item has this key present. How can i do this?

1 Answer 1

1

You should use isset():

if ( isset( $item_data['name'] ) ) {
    // your code 
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.