Pular para o conteúdo Pular para a barra lateral

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.
  • Just after this code:
    					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 );
    					}
    
  • Add this:
    					$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.

2 respostas para “WooCommerce Product Bundles - Bundled Products Not Synced in Translations”

  1. Just tested this, because none of my bundles worked anymore after the latest updates. All showed “0” as price, because the translated single items were not attributed to the translated bundles.

    Did not work. Replaced the code in the php file as indicated, deleted translations (English and French from German) and translated one from anew to test -> still did not find / connect the translated items. Price 0, empty bundle.

    This needs to be fixed quickly. Worked before.

    • Hello Oliver,
      It seems like a different case than the one reported here and it needs some investigation.
      Could you please open a chat in our support forum? In that way, one of specialists will be able to investigate your case.
      Regards

Deixe uma resposta

Por favor mantenha-se no assunto e seja respeitoso com os outros. Se precisar de ajuda com problemas não relacionados a este post, use nosso Fórum de Suporte para iniciar um chat ou enviar um ticket.

Você pode usar estas tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>