WPML

문제 개요

WPML과 함께 YITH WooCommerce Ajax Search를 사용할 때 다음과 같은 문제가 발생할 수 있습니다. WooCommerce Multilingual 다중 통화를 사용할 때 검색 결과의 가격이 상점 통화 금액에 쇼핑객의 통화 기호가 붙어 표시됩니다. 다른 언어로 동일한 검색을 한 직후 “더 보기” 검색을 하면 해당 언어의 제품이 표시될 수 있습니다. 플러그인 설정에 저장한 검색 양식 텍스트가 문자열 번역에 나타나지 않습니다. 그리고 URL에 언어를 매개변수로 사용하는 경우, “모든 제품 보기”가 모든 언어의 제품이 포함된 결과 페이지를 기본 언어로 엽니다.

임시 해결 방법

WPML설정사용자 정의 XML 구성으로 이동하여 이 코드를 추가하고 저장하세요:

XML
<wpml-config><admin-texts><key name="yith_wcas_shortcodes_list"><key name="default"><key name="options"><key name="search-input"><key name="placeholder"/></key></key></key></key></admin-texts></wpml-config>
그런 다음 WPML문자열 번역에서 자리 표시자를 번역하세요.
가격 및 페이징된 결과의 경우, 테마의 functions.php 파일에 다음 코드를 추가하세요:
PHP
add_filter( 'ywcas_store_search_query', '__return_false' );
add_filter( 'ywcas_search_result_data', function ( $data ) {
  foreach ( (array) $data as $i => $r ) {
    $r = (array) $r;
    foreach ( [ 'min_price', 'max_price' ] as $k ) { if ( isset( $r[ $k ] ) ) { $r[ $k ] = (float) apply_filters( 'wcml_raw_price_amount', (float) $r[ $k ] ); } }
    $data[ $i ] = $r;
  }
  return $data;
}, 20 );
사이트에서 언어를 URL의 매개변수로 사용하는 경우(WPML설정언어 URL 형식), wp-content/mu-plugins/에 이 코드를 포함하는 파일(예: wpml-ywcas-results-page.php)을 생성하세요. 이 코드는 WPML이 언어를 설정하기 전에 실행되어야 하므로 functions.php에서는 작동하지 않습니다:
PHP
<?php
// 1. The block's results URL: remove WPML's ?lang= from the site URL.
add_filter( 'ywcas_block_common_localize', function ( $data ) {
    if ( isset( $data['siteURL'] ) ) {
        $data['siteURL'] = strtok( (string) $data['siteURL'], '?' );
    }
    return $data;
} );
// 2. The results page: WPML gets the language code, the plugin its locale.
if ( isset( $_GET['ywcas'], $_GET['lang'] ) && false !== strpos( (string) $_GET['lang'], '_' ) ) {
    global $wpdb;
    $wpml_ywcas_locale = sanitize_text_field( wp_unslash( $_GET['lang'] ) );
    $wpml_ywcas_code   = $wpdb->get_var( $wpdb->prepare( "SELECT code FROM {$wpdb->prefix}icl_languages WHERE default_locale = %s", $wpml_ywcas_locale ) );
    if ( $wpml_ywcas_code ) {
        $_GET['lang'] = $_REQUEST['lang'] = $wpml_ywcas_code;
        // WPML reads the language from the URL itself, not only from $_GET.
        foreach ( [ 'REQUEST_URI', 'QUERY_STRING' ] as $wpml_ywcas_key ) {
            if ( isset( $_SERVER[ $wpml_ywcas_key ] ) ) {
                $_SERVER[ $wpml_ywcas_key ] = str_replace( 'lang=' . rawurlencode( $wpml_ywcas_locale ), 'lang=' . $wpml_ywcas_code, (string) $_SERVER[ $wpml_ywcas_key ] );
            }
        }
        add_action( 'pre_get_posts', function () use ( $wpml_ywcas_locale ) {
            $_GET['lang'] = $_REQUEST['lang'] = $wpml_ywcas_locale;
        }, 9999998 );
    }
}

모든 알려진 문제

이 문제에 대한 도움이 필요하십니까?

지원 문의를 하시면 저희가 함께 살펴보겠습니다.