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. How can I show an empty WooCommerce cart? [closed]
  22. Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?
  23. What is the action hook for an order that fails on frontend checkout in WooCommerce?
  24. How to unhook a function in Woocommerce Template?
  25. WooCommerce: Adding Order Item Meta Data That’s Hidden
  26. Using a filter with multiple parameters and $this
  27. Remove Order List Row Link in WooCommerce Admin?
  28. Get rid of product images mobile swipe functionality from WooCommerce single product [closed]
  29. Which hook should I use to capture $_POST(‘password’) via profile update and password reset
  30. Edit WooCommerce product content based on category
  31. Bulk remove post meta
  32. How to create html block to display extra information on woocommerce single product page
  33. woocommerce_package_rates not fired everytime
  34. differentiate hooks and filters on the same page [closed]
  35. WP_Query with meta_query for children
  36. ‘profile_update’ hook alternative for WooCommerce user meta data
  37. How to add a user custom field into Woocommerce emails?
  38. Woocommerce custom meta fields, sort by date
  39. How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
  40. Add Stripe Connect data to wc_stripe_payment_request
  41. Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
  42. How to subscribe free subscription on user registration in woocommerce subscription plugin?
  43. How to list all WC products by their attributes values?
  44. Showing the WordPress standard text area on a Woocommerce Single Product Page?
  45. Woocommerce Moving Review Below add to cart breaks button
  46. How to upload multiple image using wp_insert_post
  47. WooCommerce order complete email logic
  48. Set default value field meta_Value [closed]
  49. How to override Woocommerce functionality in Reports section?
  50. how can use woocommerce add to cart popup?
  51. How to Update the Order-Items While Editing an Order on the WooCommerce Admin Order Screen [closed]
  52. WooCommerce Hook: Content get’s displayed twice and not AFTER the order total
  53. Is it possible to update the total price on the checkout page in woocommerce from a custom field
  54. New field on checkout is shown but it’s not saved on the order details [closed]
  55. Adding Product Name on Admin Panel Order list and User’s My-Account Order List
  56. How to re-arrange this hooked content?
  57. update_post_meta not work [closed]
  58. How to exclude a taxonomy from shop & search page wooCommerce?
  59. WooCommerce order refund get qty refunded
  60. Redirect no product url’s to static url
  61. Adding a custom Shipping methods field to an order
  62. What Hook/Action is performed when a field in checkout form is changed in WooCommerce
  63. How to change a WooCommerce Subscription Deposit and Monthly Payment? [closed]
  64. How can I add a so i can show sale price under normal price
  65. password_reset doesnt work
  66. WooCommerce checkout page price break down table hook
  67. How to output woocommerce products to a page, style and modify the html structure
  68. Filter default_content only for products
  69. Woocommerce – Adding row to cart table
  70. Conditional action hook
  71. How can I override wp_price woocommerce function in my theme
  72. WooCommerce Bookings Plugin Not Saving Order ID
  73. Add a custom class to the body tag using custom fields
  74. manage_shop_order_posts_custom_column() hook is Not working In Functions.php file in my WordPress active theme
  75. Display custom product option in admin order details
  76. Next/Previous Product with custom order by price & products inside the product category [closed]
  77. WooCommerce Meta
  78. How to alter taxes amounts when updating an order
  79. How to check if woocommerce_order_item_name is use in email?
  80. Hooks For Design variation in woo commerce single product page
  81. How to add woocommerce products header title in woocommerce_breadcrumb hook to function.php
  82. Use ID as slug for product category by default in WooCommerce?
  83. What is the problem with these lines of code?
  84. data-value for custom woocommerce field showing in code but not visable on page load
  85. Display custom field value in woocommerce variable product via jQurey
  86. Access custom meta_data in processing order email
  87. Woocommerce : Add name filed of checkout page to buyers wordpress display name
  88. Updating order meta to have a meta entry from an item in the order
  89. Insert a custom field as a second email address to a completed order in WooCommerce
  90. dakon show vender address on checkout page
  91. Hide a shipping method if cart total is higher than an amount
  92. Add second price option based on payment method at cart item price
  93. Use a woocommerce hook to create a table and populate it with a query
  94. Custom fields in the billing address section woocommerce
  95. Woocommerce send metadata to stripe
  96. How to modify username before logging in?
  97. How to add field new in account bacs in woocommerce?
  98. WooCommerce Webhook Action When a New Product Review was Submitted/Created
  99. Woocommerce: hide “Price display suffix” when the VAT is zero
  100. Link post thumbnail image when automatically creating Woocommerce product from a WordPress post
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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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