Someone that’s familiar with this know how to use it? I can’t find any documentation on this function anywhere. and can this be used to update say for example the weight field and changing it from the default of pounds to options?
I assume the proper setup would be something like this, bu I’ve no idea what goes in type.
wpsc_update_meta($post_id, 'weight', '3', $type);
wpsc_update_meta($post_id, 'weight_unit', 'ounce', $type);
Any ideas guys? The full function is listed below.
function wpsc_update_meta( $object_id = 0, $meta_key, $meta_value, $type, $global = false ) {
global $wpdb;
if ( !is_numeric( $object_id ) || empty( $object_id ) && !$global ) {
return false;
}
$cache_object_id = $object_id = (int) $object_id;
$object_type = $type;
$meta_key = wpsc_sanitize_meta_key( $meta_key );
$meta_tuple = compact( 'object_type', 'object_id', 'meta_key', 'meta_value', 'type' );
$meta_tuple = apply_filters( 'wpsc_update_meta', $meta_tuple );
extract( $meta_tuple, EXTR_OVERWRITE );
$meta_value = $_meta_value = maybe_serialize( $meta_value );
$meta_value = maybe_unserialize( $meta_value );
$cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `".WPSC_TABLE_META."` WHERE `object_type` = %s AND `object_id` = %d AND `meta_key` = %s", $object_type, $object_id, $meta_key ) );
if ( !$cur ) {
$wpdb->insert( WPSC_TABLE_META, array( 'object_type' => $object_type, 'object_id' => $object_id, 'meta_key' => $meta_key, 'meta_value' => $_meta_value ) );
} elseif ( $cur->meta_value != $meta_value ) {
$wpdb->update( WPSC_TABLE_META, array( 'meta_value' => $_meta_value), array( 'object_type' => $object_type, 'object_id' => $object_id, 'meta_key' => $meta_key ) );
}
wp_cache_delete( $cache_object_id, $object_type );
if ( !$cur ) {
return true;
}
}
I’m not familiar with e-Commerce plugin, but I assume that this function is some kind of their own implementation of the WP
update_metadata()
function.If that’s true, then
$type
param should have the same meaning as the $meta_type param atupdate_metadata()
(e.g. post_type, taxonomy…). Also look at thewp_cache_delete()
usage at the bottom. This could give you some additional hints.