Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to update custom field in WooCommerce

Okay found it. It was a silly mistake I overlooked. I had 1 attribute (esc_attr($myField)) double inside the update_post_meta() method.

So this function works perfectly:

function woocommerce_save_fields($post_id)
    {
        $myField = $_POST['field_name'];
        if (!empty($myField))
          update_post_meta($post_id, 'field_name', esc_attr($myField));
        else update_post_meta( $post_id, 'field_name', '' );

    }

Related Posts:

  1. Conditionally run function based on custom meta value?
  2. How to add custom checkboxes from loop to WooCommerce product variation options?
  3. acf_form() – “On Update” action [closed]
  4. WooCommerce: Can’t use wc_get_products for custom REST API endpoints
  5. How to get rid of the hover zoom in WooCommerce single products
  6. What’s the difference between WC() and $woocommerce
  7. Hook and send Woocommerce data after click Place Order button
  8. WooCommerce conditional meta query
  9. WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
  10. Get updated meta data after save_post hook
  11. Show only geolocated user country into Woocommerce checkout country fields
  12. Better post meta efficiency?
  13. post meta data clearing on autosave
  14. Extend Woocommerce rest api routes fails
  15. Display info from custom fields in all images’ HTML
  16. Update meta values with AJAX
  17. Remove action on product archive page [closed]
  18. The correct way to override WooCommerce product gallery from a plugin [closed]
  19. display available size on hover, in woocommerce shop page [closed]
  20. Customize WooCommerce orders displayed shipping
  21. What is the action hook for an order that fails on frontend checkout in WooCommerce?
  22. WooCommerce: Adding Order Item Meta Data That’s Hidden
  23. Get rid of product images mobile swipe functionality from WooCommerce single product [closed]
  24. Which hook should I use to capture $_POST(‘password’) via profile update and password reset
  25. Edit WooCommerce product content based on category
  26. woocommerce_package_rates not fired everytime
  27. differentiate hooks and filters on the same page [closed]
  28. ‘profile_update’ hook alternative for WooCommerce user meta data
  29. How to add a user custom field into Woocommerce emails?
  30. Woocommerce custom meta fields, sort by date
  31. Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
  32. How to subscribe free subscription on user registration in woocommerce subscription plugin?
  33. How to list all WC products by their attributes values?
  34. Showing the WordPress standard text area on a Woocommerce Single Product Page?
  35. How to upload multiple image using wp_insert_post
  36. WooCommerce order complete email logic
  37. How to override Woocommerce functionality in Reports section?
  38. how can use woocommerce add to cart popup?
  39. How to Update the Order-Items While Editing an Order on the WooCommerce Admin Order Screen [closed]
  40. WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
  41. Is it possible to update the total price on the checkout page in woocommerce from a custom field
  42. New field on checkout is shown but it’s not saved on the order details [closed]
  43. Adding Product Name on Admin Panel Order list and User’s My-Account Order List
  44. How to re-arrange this hooked content?
  45. update_post_meta not work [closed]
  46. How to exclude a taxonomy from shop & search page wooCommerce?
  47. WooCommerce order refund get qty refunded
  48. Redirect no product url’s to static url
  49. Adding a custom Shipping methods field to an order
  50. What Hook/Action is performed when a field in checkout form is changed in WooCommerce
  51. How can I add a so i can show sale price under normal price
  52. password_reset doesnt work
  53. WooCommerce checkout page price break down table hook
  54. Filter default_content only for products
  55. Conditional action hook
  56. How can I override wp_price woocommerce function in my theme
  57. WooCommerce Bookings Plugin Not Saving Order ID
  58. Add a custom class to the body tag using custom fields
  59. manage_shop_order_posts_custom_column() hook is Not working In Functions.php file in my WordPress active theme
  60. Display custom product option in admin order details
  61. Next/Previous Product with custom order by price & products inside the product category [closed]
  62. WooCommerce Meta
  63. How to alter taxes amounts when updating an order
  64. How to check if woocommerce_order_item_name is use in email?
  65. How to add woocommerce products header title in woocommerce_breadcrumb hook to function.php
  66. Use ID as slug for product category by default in WooCommerce?
  67. What is the problem with these lines of code?
  68. data-value for custom woocommerce field showing in code but not visable on page load
  69. Display custom field value in woocommerce variable product via jQurey
  70. Woocommerce : Add name filed of checkout page to buyers wordpress display name
  71. Missing variable options on add to cart form
  72. call_user_func_array() expects parameter 1 to be a valid callback, class ‘WC_Rapyd’ does not have a method ‘install’
  73. Help to locate a woocommerce hook method
  74. Add custom field address_3 before city in user profile
  75. check shipping amount in woocommerce_after_checkout_validation?
  76. Woocommerce Disabling Auto Restocking for Cancelled Orders
  77. Parameters in woocommerce_before_add_to_cart_button hook
  78. How can i add product Accessories from front-end using custom php form?
  79. woocommerce_add_to_cart custom function called several times
  80. How to track product price changes?
  81. How to save a Woocomerce metabox input as a metadata field
  82. Display product thumbnail in Woocommerce email notifications
  83. Can’t update WooCommerce payment method title
  84. Add suffix to price html does not work
  85. With what hook do I remove WooCommerce existing Product Data Tab form fields?
  86. Woocommerce: Unique price for individual basket items
  87. Hide add to cart when product variation has no price or is unavailable
  88. Update Custom Post Meta Even if Draft
  89. WooCommerce Admin Only Email Hook
  90. Check if value exists before saving
  91. Add custom fields after post/page title
  92. Can a woocommerce hook alter the UI of a website?
  93. Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
  94. Updating order meta to have a meta entry from an item in the order
  95. dakon show vender address on checkout page
  96. Hide a shipping method if cart total is higher than an amount
  97. Add second price option based on payment method at cart item price
  98. Use a woocommerce hook to create a table and populate it with a query
  99. Custom fields in the billing address section woocommerce
  100. Woocommerce send metadata to stripe
Categories woocommerce-offtopic Tags custom-field, hooks, post-meta, woocommerce-offtopic
What should happen when a WordPress Plugin is activated across the network (Network Wide Activation)
Grab posts by multiple categories

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress