Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it’s working like charm.
Change:
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
Into :
add_action( 'woocommerce_variation_options', 'variable_fields', 10, 3 );
And change :
'value' => $variation_data['_weightdesc'][0],
Into :
'value' => get_post_meta($variation->ID, '_weightdesc', true)
Related Posts:
- How to access custom order item meta data from a meta key in WooCommerce?
- Adding existing user custom field value to a woocommerce product [closed]
- Adding Custom Text Area to WooCommerce Product
- WooCommerce conditional required checkout fields [closed]
- Include woocommerce custom field value in front-end search result
- woocommerce product custom field
- How to get customfield value by woocommerce product ID
- Conditionally hide or show woocommerce product variation in fontend by custom field
- Woocommerce: Custom fields and email shortcodes, ec_custom_field
- Bulk remove post meta
- How to create html block to display extra information on woocommerce single product page
- Display WP-Types custom fields in post [closed]
- Modifying custom order item meta from admin order view
- How to create a dropdown select of all items in an ACF field group
- How do I add an image upload, custom field to a WooCommerce product?
- WooCommerce – Adding Custom Fields To Invoice
- Woocommerce Product Custom Select List (not variation)
- jQuery – Automatic event trigger does not **really** check my form
- How to add new field to the account address?
- How to display custom field in woocommerce email orders? [closed]
- Woocommerce Retrieving custom field value from orders
- Update custom field values on edit address page woocommerce
- Woocommerce frontend edit custom fields
- Is it possible to add Term Meta Fields to a WooCommerce Attribute?
- Why does my numeric meta query work only on one meta key and not the other?
- Update custom field on the fly
- (woocommerce) How to get product id form order id & then retrieve custom meta linked to product?
- How to delete WooCommerce Products than have a specific custom field?
- WooCommerce 3 get custom variation on process order [closed]
- How to save array option as text and not integer?
- Use a different catalog image than the featured image
- Check if value exists before saving
- Add Custom field under the post title [closed]
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- price calculation from custom field (woocommerce) [closed]
- Hiding custom fields when content is empty [closed]
- Cannot save values to custom fields for variations on Woocommerce 2.4.6
- Send checkout page custom field in order email
- Extract array from custom field
- Assign class to Drop Down Selections in WooCommerce Products Custom Fields
- Using wordpress post data as input for google visualisations
- Assign/update the custom field value for all posts
- Display newest post’s custom field content on homepage, daily
- Loading scripts to the Post Edit page only
- Registration and Profile custom field
- Per site configuration
- Alternative to simple fields plugin?
- Calling custom fields for pages (not posts)
- Add More Fields to Users Pages (Admin Panel)
- how can i use custom field in query post
- Dynamically fill a post custom field with post publish date
- get_terms that have custom sticky field checked
- Users Select inside custom metabox
- filtering custom post types via meta data drop down
- Speed up / Optimize Admin Edit Post Page on Large Websites (50-150k posts, 50 custom fields per post)
- Why is my Custom Meta Box Field Inputs NOT saving?
- Filter multiple custom fields Values with Check boxes
- Get registered custom fields or post meta even if empty
- Restrict WordPress Search to Custom Field
- How to mass update custom fields for more than 20k posts
- remove initial wysiwyg editor from cms page edit
- New field on checkout is shown but it’s not saved on the order details [closed]
- List all unique custom field values?
- Build index page from custom fields
- Importing WordPress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin
- How can php be used to return data from custom fields in a post?
- Modify date query by URL parameter using pre_get_posts and $_GET
- help for user login
- The best way to collision check in WP
- Get meta field value of all catgories
- How to store meta field values
- Change Page Order by Custom Field (Magic Fields)
- How can I detect user’s timezone?
- ACF field group not showing in page
- Filter post style attribute
- Update some (not all) post titles with custom field values before running the Loop
- data-value for custom woocommerce field showing in code but not visable on page load
- Arrays in custom fields or is there a better way?
- Setting user permissions per post
- Problem Advanced Custom Fields PRO
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Weird custom fields data lost
- Showing the post only when there is title, thumbnail and the content in Custom Fields
- Custom product page’s style for printing
- query_posts -> get page_id from custom field
- Custom field group on page
- Output Custom Field value to shortcode
- Update custom table on metabox POST
- display custom media folders to wordpress media popup
- Should I store arrays in custom fields or create custom tables?
- change attachment custom field onChange event
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- Get custom field from other post in carousel
- Form fields based on custom fields
- show custom field content in jquery tabs
- Create citation and url in post using 3 custom fields with conditions for each field… So close!
- Show only first image of multiple image field
- Custom Fields after update to WordPress 6
- Multiple triggers when publishing, saving or updating a post in WordPress
- If possible a field ID transfom in a Custom Field?