Support » Plugin: WooCommerce Custom Product Data Fields » Unable to retrieve custom field

  • I’m using the wcapi function to maintain my inventory. I’m adding a custom field UPC. In the front-end, the new field shows up fine, and I can update it and can retrieve the field through the wp-admin page. However when I do a wcapi get products request, the new field isn’t returned. Here is my addition to the functions.php file:

    add_action(‘wc_cpdf_init’, ‘prefix_custom_product_data_tab_init’, 10, 0);
    if(!function_exists(‘prefix_custom_product_data_tab_init’)) :

    function prefix_custom_product_data_tab_init(){

    $custom_product_data_fields = array();

    /** First product data tab starts **/
    /** ===================================== */

    $custom_product_data_fields[‘custom_data_1’] = array(

    ‘tab_name’ => __(‘Custom Data’, ‘wc_cpdf’),

    ‘id’ => ‘_myupc’,
    ‘type’ => ‘text’,
    ‘label’ => __(‘UPC’, ‘wc_cpdf’),
    ‘placeholder’ => __(‘UPC Code goes here.’, ‘wc_cpdf’),
    ‘class’ => ‘large’,
    ‘description’ => __(‘UPC Code.’, ‘wc_cpdf’),
    ‘desc_tip’ => true,


    return $custom_product_data_fields;



  • The topic ‘Unable to retrieve custom field’ is closed to new replies.