WPML
Trạng thái
Đã giải quyết
Đã giải quyết trong
4.12.0
Plugin/giao diện liên quan
WooCommerce Dynamic Pricing

Tổng quan về lỗi

Khi sử dụng tính năng Bảng giá danh mục nâng cao từ plugin WooCommerce Dynamic Pricing, các khoản giảm giá không được áp dụng cho sản phẩm có biến thể (chỉ dành cho sản phẩm đơn giản).

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

Chúng tôi đã có bản sửa lỗi vĩnh viễn cho sự cố này, hiện đang chờ thử nghiệm toàn diện và phát hành. Trong lúc chờ đợi, bạn có thể sử dụng giải pháp tạm thời sau để khắc phục sự cố trên trang web của bạn:


  1. Tạo một bản sao lưu đầy đủ cho trang web của bạn trước khi tiếp tục.

  2. Mở wp-content/plugins/woocommerce-multilingual/compatibility/class-wcml-dynamic-pricing.php và tìm dòng 118.

  3. Thay thế phần này:
    	public function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, WC_Product $_product, $module_id, $dynamic_pricing, $cat_ids ) {
    		if ( ! $_product || ! $cat_ids || ! $this->has_requirements( $dynamic_pricing ) ) {
    			return $process_discounts;
    		}
    
    		$taxonomy   = $this->get_taxonomy( $dynamic_pricing );
    		$product_id = apply_filters( 'wpml_object_id', $_product->get_id(), 'product', true );
    
    		return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) );
    	}

    Bằng

    	public function woocommerce_dynamic_pricing_is_applied_to( $process_discounts, WC_Product $_product, $module_id, $dynamic_pricing, $cat_ids ) {
    		if ( ! $_product || ! $cat_ids || ! $this->has_requirements( $dynamic_pricing ) ) {
    			return $process_discounts;
    		}
    
    		$taxonomy   = $this->get_taxonomy( $dynamic_pricing );
    		$product_id = apply_filters( 'wpml_object_id', $_product->get_id(), 'product', true );
                    //fix for variable products
                    if  ($_product->post_type === "product_variation") {
    			$product_id = wc_get_product( $_product->get_parent_id() )->get_id();
    			$product_id = apply_filters( 'wpml_object_id', $product_id, 'product', true );
    			return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) );
    		}
    
    		return is_object_in_term( $product_id, $taxonomy, $this->adjust_cat_ids( $cat_ids, $taxonomy ) );
    	}

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