Skip Navigation

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

Problem:
The client was experiencing an issue with WooCommerce Subscriptions and WPML, even after implementing a suggested workaround.

Solution:
We recommended updating the workaround code. Here is the step-by-step solution:

// WPML Workaround for compsupp-7065<br />function wpml_compsupp7065_filter_wc_subscriptions_site_url( $url, $path, $scheme, $blog_id ) {<br /><br />    // Define your list of allowed URLs - DO NOT add staging versions here<br />    $allowed_url_list = array(<br />        'https://pulskuren.no',<br />        'https://thepulsecure.com',<br />        // Add more URLs as needed<br />    );<br /><br />    // Get the current WordPress home URL<br />    $current_home_url = home_url();<br />  $current_home_url = parse_url($url);<br />  $current_home_url = $current_home_url['host'];<br /><br />    // Check if the current home URL is in the list<br />    foreach ( $allowed_url_list as $listed_url ) {<br /><br />        if ( str_contains( $listed_url, $current_home_url) ) {<br />      // Replace the $url variable with the listed URL<br />            $url = $listed_url;<br />            add_filter('woocommerce_subscriptions_is_duplicate_site', '__return_false');<br />            break; <br />        }<br />    }<br /><br />    return $url;<br />}<br /><br />add_filter( 'wc_subscriptions_site_url', 'wpml_compsupp7065_filter_wc_subscriptions_site_url', 10, 4 );

Please note that this solution might be outdated or not applicable to your case. If the issue persists, we highly recommend checking 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, please open a new support ticket in the WPML support forum.

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 8 replies, has 2 voices.

Last updated by Osama Mersal 8 months, 2 weeks ago.

Assisted by: Osama Mersal.

Author Posts
April 12, 2024 at 5:49 am #15511317

arildB

Hi
I have tested this solution as a workaround for Woo Subscription and WPML. The error is still there. Can you please have a look and see if it needs some adjustments?

// WPML Workaround for compsupp-7065
function wpml_compsupp7065_filter_wc_subscriptions_site_url( $url, $path, $scheme, $blog_id ) {

// Define your list of allowed URLs - DO NOT add staging versions here
$allowed_url_list = array(
'hidden link',
'hidden link',
// Add more URLs as needed
);

// Get the current WordPress home URL
$current_home_url = home_url();
$current_home_url = parse_url($url, PHP_URL_PATH);
$current_home_url = $current_home_url['host'];

// Check if the current home URL is in the list
foreach ( $allowed_url_list as $listed_url ) {

if ( str_contains( $listed_url, $current_home_url) ) {
// Replace the $url variable with the listed URL
$url = $listed_url;
break;
}
}

return $url;
}

add_filter( 'wc_subscriptions_site_url', 'wpml_compsupp7065_filter_wc_subscriptions_site_url', 10, 4 );

April 14, 2024 at 11:33 am #15515613

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

First of all, sorry for the late reply; it was due to a higher workload. I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please backup your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

April 15, 2024 at 6:43 am #15517175

arildB

Hi Osama
I have a fresh staging site, but
unfortunately it doesn't not have custom domain. Can you still use this, or do you have to do a copy of the live site? It's a quite large Buddyboss/Memberpress site (over 40gb).

Cheers
Arild

April 18, 2024 at 5:05 am #15535346

arildB

Hi again Osama
I will set up an staging site with diffeent domains pr language and Woo subscription during the day or tomorrow. I belive this will be a better way for you to adjust the script.
If you provide me with the form again, I will provide you with login details for the staging server.

Kind regards
Arild

April 18, 2024 at 9:16 am #15536558

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi Arild,

Thanks for your update. I've enabled the private reply.

Best regards,
Osama

April 21, 2024 at 2:22 pm #15547409

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I've consulted our compatibility team regarding the issue and will update you as soon as I get their reply.

Best regards,
Osama

April 24, 2024 at 9:56 am #15559906

arildB

Hi
Any update regarding this case? We are in really hurry and would love to get the script fixed asap.

Cheers
Arild

April 24, 2024 at 10:32 am #15560158

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi Arild,

The issue has been escalated to our 2nd-tier support team, and I'll update you as soon as they reply.

Best regards,
Osama

April 29, 2024 at 11:52 am #15576915

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your patience. Please check if the issue is fixed. Our 2nd tier support team has added the following code (Updated Workaround) to your site.

// WPML Workaround for compsupp-7065
function wpml_compsupp7065_filter_wc_subscriptions_site_url( $url, $path, $scheme, $blog_id ) {
    
	// Define your list of allowed URLs - DO NOT add staging versions here
    $allowed_url_list = array(
        '<em><u>hidden link</u></em>',
        '<em><u>hidden link</u></em>',
        // Add more URLs as needed
    );

    // Get the current WordPress home URL
    $current_home_url = home_url();
	  $current_home_url = parse_url($url);
	  $current_home_url = $current_home_url['host'];
	
    // Check if the current home URL is in the list
    foreach ( $allowed_url_list as $listed_url ) {
		
        if ( str_contains( $listed_url, $current_home_url) ) {
			      // Replace the $url variable with the listed URL
            $url = $listed_url;
            add_filter('woocommerce_subscriptions_is_duplicate_site', '__return_false');
            break; 
        }
    }
	
    return $url;
}

add_filter( 'wc_subscriptions_site_url', 'wpml_compsupp7065_filter_wc_subscriptions_site_url', 10, 4 );

Best regards,
Osama

May 1, 2024 at 12:36 pm #15583961

arildB

The script is confirmed working. Thanks for your help.

Kind regards
Arild Bekkelund