If you don’t intend your meta field to be specific to a particular product type you can do the following ( which is what I do in my own WooCommerce extension ).
function new_post_meta () {
if (isset($_POST['location']))
update_post_meta( $post_id, 'location', json_encode($_POST['location']) );
}
add_action( 'woocommerce_process_product_meta', 'new_post_meta' );
or to limit this to a particular product type:
function new_post_meta () {
if (isset($_POST['location']))
update_post_meta( $post_id, 'location', json_encode($_POST['location']) );
}
add_action( 'woocommerce_process_product_meta_simple', 'new_post_meta' );
Where ‘simple’ is the product type.
Related Posts:
- Are there any hooks that alter the 404 logic?
- Adding onload to body
- How to get WordPress’ hooks/actions run sequence?
- How many times can I hook into the same action?
- Is there a hook before the user is authenticated?
- Remove action from plugin on other plugin
- Hook into WordPress update?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- switch_to_blog(): Load textdomain
- Can I hook inside another hook?
- Adding function directly vs using hook in function.php
- What is the action hook for save media-form on gallery tab?
- Filter Hook on plugin update
- WordPress Hook that will run when media file deleted
- Check if action hook exists before adding actions to it
- Generic plugin (de)activation hook?
- after login that will redirect user role into a page
- Adding a form at the end of the content
- Use external link in the add sub menu
- Access post meta just after publishing
- update post meta using user_register hook not working
- how to create endpoint for downloading pdf files?
- hook to get (and change) the search string before processing
- How can I filter blog name?
- Is there a recover_post hook to go with trash_post hook?
- How to override languages files in wp-content/languages/themes with child theme
- hooks & filters and variables
- How to increase password requirements for registration [closed]
- Can user_register output the password?
- Run add_action hook if condition
- Gutenberg gallery hook errors
- How to change title attribute returned by comments_popup_link()?
- How to use do_action_ref_array?
- WordPress action and filter hooks runs asynchronously?
- Prevent attachment from being deleted
- add action for displaying posts using a shortcode
- Update post meta using pending_to_publish hook
- Pass info from functions.php to plugin
- Get log of function/method calls made by do_action() on WordPress initialization
- Change permalink structure hidden button edit
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- Is it possible to change image urls by hooks?
- User update hook
- get current date + 90 days and checking every day
- register_activation_hook not updating
- Redirect customer to login if not logged in when proceeding to checkout
- PHP header() gives headers already sent
- Hook into existing tinyMCE button
- Send along login credentials with comment content
- How to replace a function using a child theme?
- WP_query hooks before execute a search query
- How to pass argument to wp_footer hook with data from a template
- Redirecting from login
- How to use a 3rd party library to send emails?
- I would like to send a notification email (Asana) whenever something is published (posts, pages, custom post types) [duplicate]
- Woocommerce table is missing a heading–can I add it by use of a hook?
- the_post hook is not firing for me
- Plugin Development – Functions or Hooks?
- Alternative to new_to_publish Hook for Custom Statuses
- How to remove js ui library added by default by wordpress
- How to use the pre_option filter before a plugin loads?
- WordPress plugin activation, deactivation and uninstall hook not being triggered
- Hook for inserting?
- How to remove a class function from a plugin by using remove_action()?
- profile_update hook doesn’t works inside a class
- How to stop WordPress from updating the post meta
- Plugin: Hooking up classes that have their own hooks
- Hook for altering the content of all wp mails
- wordpress post_where set only for my costum post type
- What hook can I use to modify custom post data before it is displayed on the page?
- Thickbox ‘tb_unload’ function being called twice
- How to remove a meta description or other contents
- Hooking save_post breaks check for term in added_term_relationship hook?
- Why does “updated_post_meta” did not fire when uploading media other than image?
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Restrict editing of post type to list stored in user meta
- Delay action unltil the untill previous (hoocked) action is completed
- Rewrite the search page to use an appended slug + parameter
- Add stuff above header edit form
- Callback hooked to post_updated firing on new posts as well
- do_action not working in loop
- add_action doesn’t work for my function
- Customize plugin templates
- WP_mail() Issue. Duplicate emails if $_GET[‘A’] == email
- Can add_image_size be added earlier
- Hook to change Author Info
- Admin page and admin menu. Permissions plugin
- How should I use a plugin function as a hook?
- Send email to post author 1 day before his project ends
- can’t access dashboard and showing forbidden page
- Query author’s posts & posts that have author’s id as meta value
- How to display a link in the footer section
- What is meaning of BEFORE and AFTER in this hook name?
- How to display before H1 Title
- How to Add Extra Text In WordPress Title Before Post Publish
- WP: Override/update the_content from database with the publicly echo the_content
- What is the equivalent hook for both admin_head() and wp_head() combined, if any?
- Search WordPress Hook for completed Elementor Update
- How to filter the URL of thumbnail size in the Media Grid and admin pages