• Resolved fkoomek

    (@fkoomek)


    Hello.
    I’ve already tried 2 plugins including yours and have the same problem.
    I am using Polylang (2 languages set) on my site and when I have set to show slugs for both of my languages (in Polylang settings), Paypal payment doesn’t work. I every time land on not found page of my site. When I set to not show slug for default language, it works correctly.

    Second thing. After successful redirection to Paypal, I wish the Paypal would be in the language which customer selected on the site.
    Although Paypal supports both – Czech and English this doesn’t work.
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter fkoomek

    (@fkoomek)

    You can test this behavior on this test site https://liber.behindthestars.net/

    Plugin Contributor angelleyesupport

    (@angelleyesupport)

    Hi @fkoomek,

    We have not get a chance to test the working with Polylang , also, we do have settings in PayPal for woocommerce > express checkout settings to send WP local ( language ) code to PayPal so the user should land on the page of selected language. But again I’m not if that settings may work with this plugin but you can give it a shot and see if that makes any difference.

    Thanks!

    Thread Starter fkoomek

    (@fkoomek)

    Hello. Still trying to find a solution with no luck.
    I got an idea.
    It’s not the best the solution, actually it’s quite a bad solution, but nothing better (I am not a developer) came to my mind.
    So, I found out that the problem is that when I click on Proceed to Paypal button on the Checkout page I am redirected to URL like this: domain.com/wc-api/WC_Gateway_PayPal_Express_AngellEYE/?pp_action=set_express_checkout&utm_nooverride=1

    The thing is that the Checkout page slug, which is like /en/checkout/ (/cs/kosik/) is erased.
    When I try to manually add this to the URL stated above, so the URL is now like domain.com/checkout/en/wc-api/WC_Gateway_PayPal_Express_AngellEYE/?pp_action=set_express_checkout&utm_nooverride=1
    I am correctly proceed to Paypal. I am even landing on the right Paypal page by language.
    Is it somehow possible to add the slug /en/checkout/ (/cs/kosik/) before the /wc-api/WC_Gateway_PayPal_Express_AngellEYE…. ??
    I could add this directly to the code, if you’d tell me where.
    I am using Paypall Express gateway.
    Thanks

    Thread Starter fkoomek

    (@fkoomek)

    Although the locale feature still doesn’t work, I solved this problem by modifying /plugins/woocommerce/includes/class-woocommerce.php function on line 616 from:

    	public function api_request_url( $request, $ssl = null ) {
    		if ( is_null( $ssl ) ) {
    			$scheme = wp_parse_url( home_url(), PHP_URL_SCHEME );
    		} elseif ( $ssl ) {
    			$scheme = 'https';
    		} else {
    			$scheme = 'http';
    		}
    
    		if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) {
    			$api_request_url = trailingslashit( home_url( '/index.php/wc-api/' . $request, $scheme ) );
    		} elseif ( get_option( 'permalink_structure' ) ) {
    			$api_request_url = trailingslashit( home_url( '/wc-api/' . $request, $scheme ) );
    		} else {
    			$api_request_url = add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) );
    		}
    
    		return esc_url_raw( apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl ) );
    	}

    to

    
    public function api_request_url( $request, $ssl = null ) {
    		    $currentlang = get_bloginfo('language');
                switch ($currentlang) {
                case "cs-CZ":
                $lang = "/cs";
                break;
                case "en-GB":
                $lang = '/en';
                break;
                default: $lang = '/en';
        };
    		if ( is_null( $ssl ) ) {
    			$scheme = wp_parse_url( home_url(), PHP_URL_SCHEME );
    		} elseif ( $ssl ) {
    			$scheme = 'https';
    		} else {
    			$scheme = 'http';
    		}
    
    	    if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) {
            $api_request_url = trailingslashit( home_url( $lang . '/index.php/wc-api/' . $request, $scheme ) );
        } elseif ( get_option( 'permalink_structure' ) ) {
            $api_request_url = trailingslashit( home_url( $lang . '/wc-api/' . $request, $scheme ) );
    		} else {
    			$api_request_url = add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) );
    		}
    
    		return esc_url_raw( apply_filters( 'woocommerce_api_request_url', $api_request_url, $request, $ssl ) );
    	}

    Also found a filter like

    add_filter( 'woocommerce_api_request_url', 'filter_function_name_3164', 10, 3 );
    function filter_function_name_3164( $api_request_url, $request, $ssl ){
    	// filter...
    
    	return $api_request_url;
    }

    So I wouldn’t have to modify Woocommerce original files. But I dont’t know how to make the filter work. Any help, please? ??

    • This reply was modified 5 years, 11 months ago by fkoomek.
    • This reply was modified 5 years, 11 months ago by fkoomek.
    Plugin Contributor angelleyesupport

    (@angelleyesupport)

    Hi ,

    Thanks for your response. We are looking into this and will get back to you soon.

    Thanks!

    Plugin Contributor angelleyesupport

    (@angelleyesupport)

    @fkoomek,

    Well adding URL should be on the polylang plugin , and we have to run some test on that. Thanks for proposing the solution. We are going to test that may include in a future release if we found that workable for rest of the users.

    Marking this as resolved now.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Polylang problem’ is closed to new replies.