Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is developing a site using the WP Rentals theme with WPML and encounters issues with invoices not displaying correctly when switching languages on the frontend.

Solution:
We recommend the following steps:
1. Open the

/wp-content/themes/wprentals/user_dashboard_invoices.php

file.
2. Locate the code snippet around line 48 and replace it with the provided custom code that includes a workaround for WPML.
3. The new code snippet accounts for different translations of the 'Reservation fee' string and modifies the meta query accordingly when WPML is enabled.

After implementing the changes, please check if the invoices display correctly in all languages and get back to us with the results.

Please note that this solution might be outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If necessary, do not hesitate to open a new support ticket for further assistance.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Christopher Amirian 1 year, 3 months ago.

Assisted by: Christopher Amirian.

Author Posts
March 2, 2024 at 9:04 am

aimarL

I am developing and setting up WP Rentals theme with WPML.
I ran into issues for the invoices. If i switch the language on frontend then I dont see the invoice in one language, if i switch back then i will see it.

March 2, 2024 at 10:01 am
March 2, 2024 at 10:02 am #15365520

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

I spent some time and could not find a solution and this needs to be reported to the compatibility team.

To be able to report the compatibility issues we need to replicate the issue on a clean installation.
I created a clean installation of WordPress, WPML, and all necessary WPML add-ons.
You can access the WordPress dashboard using the link below:

hidden link

Kindly follow the steps below:

- Install WP Rentals theme.
- Install the necessary plugins.
- Try to replicate the issue.

This will help us to report the probable issue to the compatibility team and solve the possible problem faster.

March 6, 2024 at 11:15 pm #15381752

aimarL

Hello,

I set up wp rentlals and configured wpml accrdingly to their documentation wpml team gave at hidden link

I was able to recreate the same issue on the WPML test site.

Please log in with the user and navigate to invoices page. If you switch to english language, then you dont see the invoice. Other pages worked in both language, for example: /my-bookings/

The "My Bookings" and "Invoices" page was translated to Finnish with DUPLICATE option.

finnish: hidden link
english: hidden link (ISSUE)

username: newuser
password: Newpassword123

Screenshot 2024-03-06 at 23.11.51.png
Screenshot 2024-03-06 at 23.11.17.png
March 9, 2024 at 3:42 pm #15391687

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

Thank you very much. The issue is reported to the compatibility team.

I will get back to you as soon as I have news.

Thanks.

March 16, 2024 at 6:30 am #15416330

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

I have an answer from the second tier support:

- Open the /wp-content/themes/wprentals/user_dashboard_invoices.php file
- Replace the following snippet around line 48:

<?php
    $args = array(
        'post_type'        => 'wpestate_invoice',
        'post_status'      => 'publish',
        'posts_per_page'   => -1 ,
        'author'           => $userID,
        'meta_query'       => array(
                array(
                    'key'       => 'invoice_type',
                    'value'     =>  esc_html__( 'Reservation fee','wprentals'),
                    'type'      =>  'char',
                    'compare'   =>  'LIKE'
                    )
        ),
    );



    $prop_selection = new WP_Query($args);

- With:

<?php
    /*
    * >> WPML Workaround for compsupp-7254
    */

    // Original meta query
    $meta_query_value = esc_html__( 'Reservation fee','wprentals');
    $meta_query_compare = 'LIKE';

    // Modify meta_query if WPML is enabled
    if ( class_exists ('Sitepress') ) {

        $meta_query_value = [];
        $meta_query_value[] = esc_html__( 'Reservation fee','wprentals');

        $wpml_current_language = apply_filters( 'wpml_current_language', NULL );
        $wpml_languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' );

        if ( ! empty( $wpml_languages ) ) {

            foreach( $wpml_languages as $language ) {
                // wpml_translate_single_string filter is not working because this string does not have a registered name
                // Because of that, we will need to switch languages (then restore it later)
                do_action( 'wpml_switch_language', $language['language_code'] );
                $translated_string = esc_html__( 'Reservation fee','wprentals');

                if ( ! in_array($translated_string, $meta_query_value) ) {
                    $meta_query_value[] = $translated_string;
                }  
            }

            // Restore original language
            do_action( 'wpml_switch_language', $wpml_current_language );
        }

        $meta_query_compare = 'IN';
    }

    $args = array(
        'post_type'        => 'wpestate_invoice',
        'post_status'      => 'publish',
        'posts_per_page'   => -1 ,
        'author'           => $userID,
        'meta_query'       => array(
            array(
                'key'       => 'invoice_type',
                'value'     =>  $meta_query_value,
                'type'      =>  'char',
                'compare'   =>  $meta_query_compare,
            )
        ),
    );
    
    $prop_selection = new WP_Query($args);

Please get back to us with the result.

Thanks.

March 16, 2024 at 10:41 am #15416547

aimarL

The code changes fixed the issue with the invoices.

Thanks.