Home Forums WC Vendors Pro Support Custom product post meta

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16346
    Stephen
    Participant

    Looks like a small bug. Quite an ironic one actually.

    I moved all my custom product meta values in 1.0.5 from _gf_* to _wcv_custom_* to be more in line with wcvendors when I ditched gravity forms ( bloody awful thing to work with! ).

    Looks like you had a similar idea in 1.1.0 and created a section in the save_meta function of the product controller to iterate through any similarly named variables and save them. Unfortunately the update_post_meta() call uses store_id instead of post_id.

    I use the action just after, at the end of the function to save the meta data. The function has a bit of extra validation and deals with other things as well so would prefer to use that.

    There’s an argument that custom meta data isn’t standard and should be dealt with on an ad hoc basis not with a straight no-validation update/insert.

    As well as the fix to the variable name I would also request/recommend that the key capture applies a filter to let the user bypass it, so:

    
    // To be used to allow custom meta keys 
    $wcv_custom_metas = array_intersect_key( $_POST, array_flip(preg_grep('/^_wcv_custom_product/', array_keys( $_POST ) ) ) );
    
    if ( !empty( $wcv_custom_metas ) ) { 
    
    foreach ( $wcv_custom_metas as $key => $value ) {
    	update_post_meta( $store_id, $key, 	$value ); 	
    }
    
    }
    

    to:

    
    // To be used to allow custom meta keys 
    $wcv_custom_metas = apply_filters( 'wcv_custom_product_meta', array_intersect_key( $_POST, array_flip(preg_grep('/^_wcv_custom_product/', array_keys( $_POST ) ) ) ) );
    
    if ( !empty( $wcv_custom_metas ) ) { 
    
    foreach ( $wcv_custom_metas as $key => $value ) {
    	update_post_meta( $post_id, $key, 	$value ); 	
    }
    
    }
    

    Thanks.

    #16400
    Stephen
    Participant
    #16403
    Jamie
    Keymaster

    Hi Stephen,

    Thanks for that, I’ve updated the post_id and also to make sure both our custom meta key systems have the same naming scheme in the next release the code will add an _ at the end so it will now be

    Product:
    _wcv_custom_product_ instead of _wcv_custom_product.

    Store:
    _wcv_custom_settings_

    cheers,

    Jamie.

    #16583
    WC Vendors Support
    Participant

    1.1.1 is live now, and this update is now included. Have fun.

    Ben

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.