update_meta_data()
18th January 2021
0 Comments
Framework / CMS
WooCommerce [Version: Since 2.6.0]
Syntax
Typical Usage
Updates WooCommerce order meta data by key or ID, if provided.
Accepted Parameters
- key (string) (Required): The meta key to add or update.
- value (string or integer) (Required): The value to insert.
- meta_id (integer) (Optional): The meta_id to lookup.
Return Value(s)
Mixed.Examples of update_meta_data()
Example 1
<?php
$user_id = get_current_user_id();
$args = array(
'customer_id' => $user_id
);
$new_order = wc_create_order($args);
$new_order->update_meta_data('_employee_code', 1234);
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.