WPML
Trạng thái
Đang mở
Được báo cáo cho
WPML Multilingual & Multicurrency for WooCommerce 5.5.3.1
Plugin/giao diện liên quan
WooCommerce Product Bundles
Thẻ chủ đề
WCML

Tổng quan về lỗi

Khi dịch một sản phẩm theo gói bằng WooCommerce MultilingualWooCommerce Product Bundles, bạn có thể thấy rằng sản phẩm đã dịch bị thiếu tất cả các mặt hàng trong gói. Sự cố này xảy ra khi có sự không nhất quán trong cơ sở dữ liệu, ngăn cản việc đồng bộ hóa đúng cách dữ liệu sản phẩm theo gói trong bản dịch.

Giải pháp tạm thời

Vui lòng đảm bảo bạn đã sao lưu toàn bộ trang web của mình trước khi tiếp tục.


  • Mở tệp …/woocommerce-multilingual/compatibility/WcProductBundles/class-wcml-product-bundles.php.

  • Ngay sau đoạn mã này:
    					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 );
    					}


  • Thêm đoạn mã sau:
    					$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,
    							]
    						);
    					}


  • Cuối cùng, lưu lại sản phẩm gốc.

Tất cả các lỗi đã ghi nhận →