跳过导航

Open

Topic Tags: Compatibility

Overview of the issue

If you are using WooCommerce Subscriptions with a WPML language-per-domain setup, you might encounter a notice incorrectly warning about a potential staging or duplicate site. This issue can arise when automatic payments are enabled on one domain and then checked on another domain within the same setup.

It looks like this site has moved or is a duplicate site. WooCommerce Subscriptions has disabled automatic payments and subscription related emails on this site to prevent duplicate payments from a staging or test environment. WooCommerce Subscriptions considers https://www.domain.com to be the site’s URL. Learn more ».

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following snippet:
    // 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(
            'https://www.domain.com',
            'https://www.domain.nl',
            // 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 );
    
  • Edit it and add your site’s URL domains instead of the example.

2 所有回复 给 “WooCommerce Subscriptions - It looks like this site has moved or is a duplicate site”

留下回复

紧扣主题并尊重他人。如果您需要帮助解决与本帖无关的问题,请使用我们的 Support Forum 开始聊天或提交票据。

您可以使用这些标签:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>