Hi,
This is David from the WPML compatibility team. We recently had a bug report in our forum about using Custom Related Products together with WPML.
We put together a small snippet that translates the related product ids on the fly to make it work:
add_action( 'init', 'wcrp_wpml_loaded' );
function wcrp_wpml_loaded() {
if ( apply_filters( 'wpml_setting', false, 'setup_complete' ) ) {
add_filter( 'get_post_metadata', 'wcrp_translate_related_ids', 10, 4 );
}
}
function wcrp_translate_related_ids( $value, $post_id, $meta_key, $single ) {
global $wpdb;
if ( '_wcrp_related_ids' === $meta_key ) {
$ids = maybe_unserialize( $wpdb->get_var( $wpdb->prepare(
"SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s",
$post_id,
$meta_key
) ) );
$value = array();
foreach ( $ids as $id ) {
$value[] = apply_filters( 'wpml_object_id', $id, get_post_type( $id ), true );
}
$value = array( $value );
}
return $value;
}
If you have a child theme, you can place this code in functions.php in the child theme. This is the quickest way.
But ideally, the plugin author can include it directly in the plugin.
Best
David