Recommended Free Tools
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
Use update_meta_data() on a loaded WooCommerce CRUD object, then call save(). For a product, load it with wc_get_product(); for an order, use wc_get_order(). Validate the value first, keep the key stable, and pass a metadata ID when duplicate rows must be distinguished. This approach follows WooCommerce’s CRUD layer, so the configured data store—not a direct WordPress post update—controls persistence.
What update_meta_data() actually does
update_meta_data() is a method of WooCommerce’s WC_Data objects. Products, orders, customers, and other CRUD-backed records expose it through their object classes. The method changes the object’s metadata collection in memory; it does not by itself write the change permanently. Persistence occurs when you call save().
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →WooCommerce introduced CRUD objects in version 3.0. Its developer documentation recommends using these objects whenever possible instead of directly updating metadata or manipulating WordPress post objects. A CRUD object gives WooCommerce a consistent place to validate properties and delegate storage to the configured data store.
Arguments and return behavior
| Argument | Purpose | What to supply |
|---|---|---|
$key |
Metadata name | A stable string such as _acme_external_ref |
$value |
New metadata value | A validated scalar or array appropriate for the field |
$meta_id (optional) |
Selects one row when the same key appears more than once | The real metadata row ID; omit it for normal key-based updates |
With no metadata ID, WooCommerce applies its key-based metadata handling. The exact persistence operations are owned by the data store. If you pass an ID, WooCommerce can target that particular row even when several rows share the same key.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
Why save() is mandatory
CRUD setters queue changes on the object. WC_Data::save() delegates create or update work to the configured data store; WooCommerce’s documentation describes save as creating or updating according to whether the object already exists. If execution ends, the object is discarded, or another process reloads the record before you save, the unsaved mutation is lost. Make the final save() call after all metadata changes for that object.
Update product metadata in PHP
The usual pattern is to load the product through its CRUD class, reject an invalid ID, normalize incoming data, update the key, and save once.
<?php
$product = wc_get_product( $product_id );
if ( ! $product ) {
return;
}
$value = sanitize_text_field( wp_unslash( $_POST['external_ref'] ?? '' ) );
$product->update_meta_data( '_external_ref', $value );
$product->save();
What each step protects
- Load the object.
wc_get_product()returns the appropriate product CRUD object. The early return prevents a method call on a missing or invalid product. - Normalize the input. The example removes slashes added to request data and applies text sanitization. Use a validator that matches the field’s real type rather than copying this sanitizer for every field.
- Use one canonical key. The same spelling, capitalization, and leading underscore must be used everywhere the value is read or written.
- Persist the mutation. Calling
save()hands the changed object to WooCommerce’s data store.
If several metadata values belong to the same product, call update_meta_data() for each one and call save() once at the end. This keeps one logical update together and avoids relying on an intermediate in-memory state.
Update order metadata
Orders use the same CRUD contract, but must be loaded with wc_get_order().
<?php
$order = wc_get_order( $order_id );
if ( ! $order ) {
return;
}
$order->update_meta_data( '_fulfillment_note', $note );
$order->save();
Validate $note according to your field definition before this code runs. For administrator forms, also enforce the capability required to edit the order and verify the form nonce. Metadata attached to an order is not a substitute for WooCommerce’s own order properties or status transitions.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Update one duplicate metadata row by ID
Key-based updates are suitable when a key represents one current value. Legacy imports and integrations sometimes leave multiple rows with the same key. In that situation, identify the exact metadata row and pass its ID as the third argument.
Free tools Windows power users keep installed
One-click scans. No signup required.
<?php
$product = wc_get_product( $product_id );
if ( ! $product ) {
return;
}
$meta_id = 123; // Obtain the real metadata row ID for this product.
$product->update_meta_data( '_legacy_code', 'NEW-VALUE', $meta_id );
$product->save();
The number in this example is illustrative; your application must obtain the actual row ID belonging to that product. Supplying an ID is the way to distinguish one duplicate from another. Omitting it invokes WooCommerce’s normal key-based handling, whose choice of matching row is controlled internally rather than by an assumption that every duplicate will be updated.
Replacing a value versus keeping multiple values
Decide the data model before choosing the call. The method name does not mean “append another row” in every situation.
| Requirement | Recommended design | Important implication |
|---|---|---|
| One current external reference | One stable key and a key-based update_meta_data() call |
Readers should expect one current value. |
| Several values intentionally share a key | Define the multi-value format and its read behavior explicitly | Test how every consumer handles the values; do not assume a generic update appends. |
| One particular legacy duplicate must change | Pass that row’s metadata ID | Do not rely on key matching to select the desired duplicate. |
| A list belongs conceptually to one field | Use an array value only when the consuming code is designed for it | Validate the array shape and document its meaning. |
WooCommerce accepts scalar and array values, but the storage and retrieval details remain the data store’s responsibility. Define whether an array is one serialized field value or whether separate rows are required by your integration, then test the read path accordingly.
Name, validate, and secure custom metadata
Choose collision-resistant keys
Prefix keys with a plugin or integration identifier, for example _acme_external_ref, rather than using a generic name such as status or note. A stable, namespaced key reduces collisions with WooCommerce core and other extensions. Record the key in one constant or schema definition so spelling changes do not create a second field.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Validate for the real type
- Text identifiers should be bounded to the characters and length your external system accepts.
- Numeric values should be parsed and range-checked as numbers, not merely sanitized as text.
- Arrays should have a known shape, with each member validated before the update.
- Empty input should have an explicit meaning: reject it, clear the field, or preserve the previous value.
Sanitization makes data safer to store, but it is not a substitute for validation. A value can be safely encoded and still be invalid for an API, identifier format, or business rule.
Protect administrator forms
When a value originates in an administrator form, verify a nonce and the user’s capability before loading and changing the object. Do not treat a hidden product or order ID as authorization. Apply the same checks to AJAX handlers and background requests that accept user-controlled identifiers.
Keep read and write keys identical
A leading underscore is part of the key. Reading external_ref after writing _external_ref returns a different field. Centralize the key and use the same exact string for form processing, display, exports, REST calls, and migrations.
CRUD objects versus direct WordPress metadata calls
update_post_meta() can appear to work for products and orders because those records have WordPress post storage in many installations. It is nevertheless a lower-level choice. WooCommerce recommends CRUD objects whenever possible because the object and its data store are the compatibility boundary.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Decision axis | WooCommerce CRUD object | Direct WordPress metadata call |
|---|---|---|
| Typical code | Load with wc_get_product() or wc_get_order(), call update_meta_data(), then save() |
Call a WordPress metadata function with a post ID |
| Persistence | Explicit through WC_Data::save() and the configured data store |
Writes directly through WordPress metadata APIs |
| Alternate data stores | The object delegates operations to the store WooCommerce has configured | May bypass storage behavior implemented outside the default post-meta path |
| WooCommerce properties | Supports structured getters, setters, validation, and object lifecycle | Sees only raw metadata and does not model supported WooCommerce properties |
| Best fit | Product, order, customer, and extension code that should remain compatible with WooCommerce’s CRUD layer | Code that deliberately targets WordPress post metadata and accepts that lower-level contract |
Direct metadata access is not made safer merely by using the same key. It can leave an object cache, extension hook, or alternate store out of sync. Use it only when you have a specific, tested reason not to use the CRUD object.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Use dedicated CRUD setters for core WooCommerce properties
Custom metadata is for extension-owned data. Price, stock, status, downloadable settings, and other business-critical WooCommerce properties have dedicated CRUD setters and getters. Update those properties through their structured API instead of creating a shadow key such as _my_price that another part of the system may ignore.
| Data you need to change | Where it belongs | Why |
|---|---|---|
| Extension reference, fulfillment note, synchronization token | Custom metadata | These values belong to the extension or integration. |
| Catalog price or sale price | The product’s dedicated price setter | WooCommerce knows how to expose and validate the property. |
| Inventory quantity or stock state | The product’s dedicated stock setters | Stock operations have domain-specific behavior that a custom key cannot provide. |
| Order status and totals | The order’s dedicated CRUD methods and order workflow | Other WooCommerce features depend on the structured values. |
Update metadata through the REST API
WooCommerce REST updates carry metadata in a JSON meta_data array. A minimal payload is:
{
"meta_data": [
{"key": "_external_ref", "value": "ABC-123"}
]
}
WooCommerce’s REST metadata utility normalizes entries before applying them to the target CRUD object. It skips entries without a key, supplies defaults for missing fields where appropriate, and calls update_meta_data() for valid entries. The endpoint still needs to authenticate and authorize the write; JSON syntax alone does not grant permission.
REST versus Store API
Use an authenticated WooCommerce REST endpoint for administrative or integration writes. The Store API is public and intended for customer-facing product, cart, and checkout functionality, not as a general-purpose endpoint for privileged metadata changes. Keep credentials, capability decisions, and server-side validation on the write path.
REST payload rules
- Send the exact metadata key, including any leading underscore.
- Use a value whose JSON type matches the field contract.
- Do not include keyless objects and expect them to create metadata; they are skipped.
- After a successful response, read the resource again when the update is business-critical.
How the data store affects persistence
WooCommerce data stores bridge classes such as WC_Product, WC_Order, and WC_Customer to database storage. They define how metadata is read, added, updated, and deleted. The CRUD object therefore gives your code a stable interface while allowing storage implementations to change.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
A custom data store or extension hook can alter what happens between the setter and the database. If a value appears to vanish despite correct object loading and a completed save, inspect the configured data store and hooks that run during the save lifecycle. Do not “fix” the symptom by writing a second copy with a direct WordPress function.
Debugging when update_meta_data() did not save
Work through these checks in order; each isolates a different failure mode.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute- The object is missing. Confirm that
wc_get_product()orwc_get_order()returned an object before calling the setter. Log the requested ID and handle a false result explicitly. - The key differs. Compare the write key and read key character for character. Check capitalization, whitespace, prefixes, and leading underscores.
save()never ran. Ensure the save call is reached after every metadata mutation, including branches that return early or throw an exception.- A later hook changed it. Search save-related hooks, synchronization callbacks, and import jobs that may write the same key after your code. Log the value immediately before save and after a fresh reload.
- A duplicate row was selected unexpectedly. Inspect whether the key occurs more than once. If one particular row must change, obtain its metadata ID and pass it as the third argument.
- A custom data store is involved. Check the store’s metadata implementation and any extension-specific documentation. The CRUD call is still the correct boundary, but the store may impose rules your direct database assumption missed.
- The REST request was normalized or rejected. Verify that the payload contains a key, uses valid JSON, reaches an authenticated WooCommerce endpoint, and receives a successful response. A public Store API request is not an authorized administrative write.
Read back from a fresh object
Reading the same in-memory object proves only that the setter changed that object. For a persistence check, save it, load the product or order again, and read the metadata from the new object. This distinguishes an unsaved mutation from a value that was later overwritten or stored differently.
<?php
$product->update_meta_data( '_external_ref', $value );
$product->save();
$reloaded = wc_get_product( $product->get_id() );
if ( $reloaded ) {
$saved_value = $reloaded->get_meta( '_external_ref', true );
}
Use the reloaded value for diagnostics or an assertion in an integration test. If the value is absent, continue with the object, key, duplicate, hook, and data-store checks rather than assuming the setter silently failed.
Reusable implementation patterns
Encapsulate one field’s rules
A small helper can keep naming, validation, and persistence consistent across admin forms, imports, and scheduled jobs.
<?php
function set_external_reference( $product_id, $raw_value ) {
$product = wc_get_product( $product_id );
if ( ! $product ) {
return false;
}
$value = sanitize_text_field( wp_unslash( $raw_value ) );
if ( $value === '' ) {
return false;
}
$product->update_meta_data( '_acme_external_ref', $value );
$product->save();
return true;
}
The helper returns a simple success flag, but production code should also decide how to report validation failures and save exceptions. Keep authorization outside or inside the helper deliberately; do not assume every caller has the same trust level.
Apply several fields in one save
<?php
$product = wc_get_product( $product_id );
if ( ! $product ) {
return;
}
$product->update_meta_data( '_acme_external_ref', $external_ref );
$product->update_meta_data( '_acme_sync_state', $sync_state );
$product->update_meta_data( '_acme_synced_at', $synced_at );
$product->save();
Validate each variable before this block. If one field is invalid, decide whether to reject the entire update or save only the valid fields; do not leave that policy to accidental control flow.
A practical decision guide
| Question | Choose | Reason |
|---|---|---|
| Is the record a WooCommerce product, order, or customer? | Load its CRUD object first | This is WooCommerce’s supported abstraction for storage and validation. |
| Does the key represent one current value? | Use a key-based update and save | The key is treated as the field’s current value. |
| Are duplicate rows intentional? | Define the read contract, or pass a metadata ID for one-row edits | Generic key updates do not define an append or selection policy for your business logic. |
| Is the data a core WooCommerce property? | Use its dedicated CRUD setter | Do not shadow domain values with extension metadata. |
| Is the write coming from another system? | Use an authenticated REST endpoint with JSON metadata | The REST layer normalizes metadata and enforces endpoint authorization. |
| Did a value disappear after saving? | Reload and inspect keys, hooks, duplicates, and the data store | These checks separate coding errors from later writes or storage behavior. |
The reliable pattern is consistent: load the correct CRUD object, validate a namespaced key and value, update metadata by key or explicit row ID, save once, and verify from a fresh object when the result matters. That keeps custom metadata compatible with WooCommerce’s data-store layer while leaving core commerce properties under their dedicated APIs.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

