Support » Plugin: YITH WooCommerce Product Bundles » WPML compatibility

  • This is David from the WPML compatibility team. We have had a few requests about making your plugin compatible with WPML and decided to give it a go.

    Your plugin requires a language configuration to be copied in the root folder of your plugin. It should be called wpml-config.xml and the contents would be:

            <custom-field action="copy">_yith_wcpb_bundle_data</custom-field>

    This copies the bundle data to each translation but we still need to translate the product id. For that we need to use this code somewhere:

    add_action( 'wcml_after_duplicate_product_post_meta', 'yith_woocommerce_product_bundles_sync', 10, 2 );
    function yith_woocommerce_product_bundles_sync( $original_product_id, $trnsl_product_id ) {
        $data = get_post_meta( $trnsl_product_id, '_yith_wcpb_bundle_data', true );
        if ( is_array( $data ) ) {
            $language = apply_filters( 'wpml_post_language_details', null, $trnsl_product_id );
            foreach ( $data as &$product ) {
                $product['product_id'] = apply_filters( 
            update_post_meta( $trnsl_product_id, '_yith_wcpb_bundle_data', $data );

    The code can be simply copied to functions.php in the theme, but ideally it should go in the plugin itself to avoid future support requests about this.

    If you decide to include this code in your plugin, you can use the ‘wpml_loaded’ filter so that its only executed when WPML is installed.

Viewing 1 replies (of 1 total)
  • Plugin Author YITHEMES


    Hi David,
    and thanks for taking the time to write a snippet for making the two products compatible. I appreciated it a lot.
    I have tested the code with the free version and it works up to a certain degree only. The code is good, but it is missing the part concerning viewing the items (they wouldn’t be translated correctly), the cart and others.
    We have already added a compatibility fix in the premium version of the same plugin, but making the free version requires a different fix. Yours is a great one, but is only partial. I wouldn’t feel to say that it’s WPML compatible when I’m sure there are some parts that are not working as customers would expect. Yet, we could leave this code here for any users who want to make a first step toward a more complete compatibility. What do you think?

    Best Regards
    YITH Support

Viewing 1 replies (of 1 total)
  • The topic ‘WPML compatibility’ is closed to new replies.