• Resolved .C

    (@lemonthirst)


    Hello,
    after the last update im facing a odd issue with one custom field i’ve added for my simple products / variations.

    From what i saw, when i set up a featured image for the product, the custom field gets reset, it’s empty although data has been set for that field (tech specs). This happens only when product gets updated, not when it’s a new published product.
    With the old version of Woocommerce i wasn’t having this issue, any clues on how can i fix this?

    Thank you!

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Post the code you added to add/save the field here/on gist.github.com

    Thread Starter .C

    (@lemonthirst)

    Thanks for the quick reply, sorry i’ve been away for the weekend, here is the gist with the code i am using for my custom fields

    https://gist.github.com/lemonthirst/718858f48032df453f53

    Thank you!

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    It may be your loop over the skus.

    $max_loop = max( array_keys( $_POST['variable_post_id'] ) );
    
    for ( $i = 0; $i <= $max_loop; $i ++ ) {
    // code here
    }

    Try that, in case the ids of the variations are not in order.

    Thread Starter .C

    (@lemonthirst)

    Still no luck find a fix, took a look around the class-wc-meta-box-product-data.php to see if i am missing something,
    and i’ve modified the

    if (!empty($_text_field[$i])) {
                    update_post_meta($variation_id, '_text_field', ('' === $_text_field[$i]) ? '' : $_text_field[$i]);
                }

    So that on product update/edit the field wont get erased from the db untill i will find a permanent fix.

    One odd thing is that after saving/update the value of the custom field is returned on the frontend but in the backend is empty.

    Thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘custom field empty after product update’ is closed to new replies.