You should ad the custom field to product API response, try this
(untested)
add_filter( 'woocommerce_rest_prepare_product', 'custom_products_api_data', 90, 2 );
function custom_products_api_data( $response, $post ) {
// retrieve a custom field and add it to API response
$response->data['purchasing_cost'] = get_post_meta( $post->ID, 'purchasing_cost', true );
return $response;
}
Related Posts:
- Modifying custom order item meta from admin order view
- How to get custom post meta using REST API
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- How to return Meta data from the REST API?
- How to access custom order item meta data from a meta key in WooCommerce?
- Save Custom Fields for Variations Product
- Retrieve custom fields on Categories, using WP-API
- How to filter or search the posts using postmeta tables custom meta fields with wordpress REST API
- Adding existing user custom field value to a woocommerce product [closed]
- Cannot edit post meta fields with rest API
- Adding Custom Text Area to WooCommerce Product
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- WooCommerce conditional required checkout fields [closed]
- Include woocommerce custom field value in front-end search result
- How to get customfield value by woocommerce product ID
- Register rest field for specific user
- 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]
- WordPress Rest API to call page data associate with custom meta
- Add post meta fields, when creating a post using WordPress’ REST API
- 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
- How to update only certain custom fields in a the cache of a page?
- How to add a post’s view count into the WordPress API response
- 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?
- Custom meta POST request fired twice when updating a post in Gutenberg
- Update custom field on the fly
- checking liked user in wordpress rest api
- (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
- Make Custom Fields Public in JSON – API
- 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
- Custom query with orderby meta_value of custom field
- How to enable revisions for post meta data?
- Any way to add custom options to Gallery Settings?
- Including custom fields in search?
- How to display all custom fields associated with a post?
- passing argument to get_template_part() or a better way to code
- Bulk move (or copy) from a custom field to the post content?
- Move value of one custom field to another
- little help with a mySQL query to wp database
- How do I query for a post by custom field?
- Calling custom profile fields?
- How to Display pages with a Custom Fields in one page
- Category Tree In WooCommerce Product API
- Unsaved changes in metabox inputs not detected in the block editor
- Declaring in variables [closed]
- How to populate custom field dropdown box based on prior selection?
- Saving Custom Field Data before Publish
- Hook after meta created
- Inserting data into MagicFields using mysql queries
- Custom Field box history
- Check & remove special characters in a field?
- Get emails from users by custom field SQL
- Why am I getting a “Call to member function format() on a non-object” error?
- How To Show Get Adjacent Posts If Posts Are Sorted By Custom Field
- How to calculate custom field value (average)
- Modify custom field from front end
- How to get all custom fields with some prefix in key?
- How to Convert Custom Fields from Text to Array?
- Use update_post_meta to older posts
- Best way to insert a list of links into a post outside of the_content
- Woocommerce Rest API: woocommerce_product_invalid_image_id
- WC REST API Error Handling
- Line break description wordpress
- Custom field disappeared from screen options
- ACF – Compare user and post data
- Advanced Custom Fields deleting some code and adding code for a slider
- How to format the various types of custom fields?
- Get first URL from custom field, download and set as featured image on post publish
- How to add an option to admin to add image that could be used as header?
- How to query posts that have certain post meta keys, and sort by meta key and/or value
- sort a custom field base on the date or anything
- Add image custom attribute [closed]
- Foreach giving one too many list items, how can I remove the last empty line?
- I used a custom field for header image and can’t get it to show up on posts
- querying to custom field over ACF REST API