15 1 0 4000 1 https://codeblock.co.za 300 true 0
theme-sticky-logo-alt

update_meta_data()

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);

Was This Helpful?

Previous Post
get_id()
Next Post
payment_gateways()

0 Comments

Leave a Reply