WPML
Stato
Aperto
Segnalato per
WPML Multilingual & Multicurrency for WooCommerce 5.5.3.1
Plugin/tema correlato
WooCommerce Product Bundles
Tag dell’argomento
WCML

Panoramica del problema

Quando traduci un prodotto in bundle usando WooCommerce Multilingual e WooCommerce Product Bundles, potresti notare che nel prodotto tradotto mancano tutti gli elementi in bundle. Questo problema si verifica quando c’è un’incoerenza nel database che impedisce una corretta sincronizzazione dei dati del prodotto in bundle nella traduzione.

Soluzione alternativa

Assicurati di avere un backup completo del sito prima di procedere.


  • Apri il file …/woocommerce-multilingual/compatibility/WcProductBundles/class-wcml-product-bundles.php.

  • Subito dopo questo codice:
    					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 );
    					}


  • Aggiungi questo:
    					$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,
    							]
    						);
    					}


  • Infine, salva nuovamente il prodotto originale.

Tutti i problemi noti →