Skip to content Skip to sidebar

Open

Reported for: WPML Multilingual & Multicurrency for WooCommerce 5.5.3.1

Topic Tags: WCML

Overview of the issue

When translating a bundled product using WooCommerce Multilingual and WooCommerce Product Bundles, you may find that the translated product is missing all bundled items. This issue happens when there’s a database inconsistency which prevents a proper synchronization of bundled product data in the translation.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open …/woocommerce-multilingual/compatibility/WcProductBundles/class-wcml-product-bundles.php file.
  • Replace:
    					if ( ! $translated_item_id ) {
    						$menu_order = $this->wpdb->get_var(
    							$this->wpdb->prepare(
    								" 
                                SELECT menu_order FROM {$this->wpdb->prefix}woocommerce_bundled_items
    	                        WHERE bundle_id=%d AND product_id=%d
    	                        ",
    								$bundle_id,
    								$product_id
    							)
    						);
    
    						$this->wpdb->insert(
    							$this->wpdb->prefix . 'woocommerce_bundled_items',
    							[
    								'product_id' => $translated_product_id,
    								'bundle_id'  => $translated_bundle_id,
    								'menu_order' => $menu_order,
    							]
    						);
    						$translated_item_id = $this->wpdb->insert_id;
    						$this->set_translated_item_id_relationship( $item_id, $translated_item_id, $lang );
    					}
    
  • With:
    					$check = $this->wpdb->get_var(
    						$this->wpdb->prepare(
    							"SELECT bundled_item_id FROM {$this->wpdb->prefix}woocommerce_bundled_items 
                 WHERE bundled_item_id = %d AND bundle_id = %d",
    							$translated_bundle_id,
    							$translated_product_id
    						)
    					);
    					if ( !$check ) {
    						$menu_order = $this->wpdb->get_var(
    							$this->wpdb->prepare(
    								" 
                                SELECT menu_order FROM {$this->wpdb->prefix}woocommerce_bundled_items
    	                        WHERE bundle_id=%d AND product_id=%d
    	                        ",
    								$bundle_id,
    								$product_id
    							)
    						);
    
    						$this->wpdb->insert(
    							$this->wpdb->prefix . 'woocommerce_bundled_items',
    							[
    								'bundled_item_id' => $translated_item_id,
    								'product_id' => $translated_product_id,
    								'bundle_id'  => $translated_bundle_id,
    								'menu_order' => $menu_order,
    							]
    						);
    					}
    
  • Finally, resave the original product.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>