Home Forums WoodMart support forum Variation Gallery and Swatch Not Working With WPML

Variation Gallery and Swatch Not Working With WPML

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #653914

    jimmy.xupp
    Participant

    Hi,

    After I translated the product via WPML, both varation gallery and swatch are not working, can you take a look?

    Here is the link: https://www.peilishop.com/fr/produit/echarpe-en-cachemire-a-rayures-kyla/

    Best,
    Jimmy

    #653955

    Luke Nielsen
    Keymaster

    Hello,

    You should be able to translate product variations from WooCommerce > WooCommerce Multilingual > Attributes tab and after that, you need to press the Synchronize attributes and update product variations button, please make sure to take a backup of your site first for security reasons.

    Here is a doc for more details:
    https://wpml.org/documentation/related-projects/woocommerce-multilingual/#variations

    Kind Regards

    #654043

    jimmy.xupp
    Participant

    I fixed the swatch issue, but the variation gallery is not working, when I clicked the swatches, only the featured image is changed, but the of the gallery images are not.

    Here is what the product should look like: https://www.peilishop.com/product/kyla-stripe-cashmere-scarf/

    How should I fix it?

    #654172

    Luke Nielsen
    Keymaster

    Hello,

    Currently, it changes, here is a video – https://dropmefiles.com.ua/en/9e3GKWAk

    Let me know if you have sorted it out.

    Kind Regards

    #654369

    jimmy.xupp
    Participant

    Yes, the original product in English is working well, but it’s not working in translated language, https://www.peilishop.com/fr/produit/echarpe-en-cachemire-a-rayures-kyla/

    How should I make it work? Hope you understand what I mean.

    #654507

    Luke Nielsen
    Keymaster

    Hello,

    Okay, I see. May I disable 3rd party plugins for testing?

    I await your response.

    Kind Regards

    #654794

    jimmy.xupp
    Participant

    Please test on this staging site: https://wordpress-1447784-5427290.cloudwaysapps.com/

    Same login credential as the live site.

    #655266

    Luke Nielsen
    Keymaster

    Hello,

    Add the code below to the child theme and recheck the issue:

    add_action('init', function () {
    	remove_filter( 'woocommerce_available_variation', 'woodmart_avi_update_available_variation', 10, 3 );
    });
    
    function wd_avi_update_available_variation( $available_variation, $variation_object, $variation ) {
    	if ( ! woodmart_get_opt( 'variation_gallery' ) ) {
    		return $available_variation;
    	}
    
    	$product_id          = $variation->get_parent_id();
    	$default_images_data = woodmart_avi_get_default_data( $product_id );
    	$variation_id        = apply_filters( 'wpml_object_id', $available_variation['variation_id'], 'product_variation', true );
    
    	$images_data         = get_post_meta( $variation_id, 'wd_additional_variation_images_data', true );
    	$ids                 = array_filter( explode( ',', $images_data ) );
    
    	if ( has_post_thumbnail( $variation_id ) ) {
    		$available_variation['additional_variation_images'][] = woodmart_avi_get_image_data( get_post_thumbnail_id( $variation_id ), true );
    	}
    
    	foreach ( $ids as $id ) {
    		$available_variation['additional_variation_images'][] = woodmart_avi_get_image_data( $id );
    	}
    
    	if ( $default_images_data ) {
    		$available_variation['additional_variation_images_default'] = $default_images_data;
    	}
    
    	return $available_variation;
    }
    
    add_filter( 'woocommerce_available_variation', 'wd_avi_update_available_variation', 10, 3 );

    Kind Regards

Viewing 8 posts - 1 through 8 (of 8 total)