• Resolved Alejandro J. Sanchez P.

    (@elpanda13gmailcom)


    Hi guys, i just wanted to let you know about an improvement you can make that would make the plugin automatically WPML Compatible and will use the WordPress best practices since there is something that you are doing that you shouldn’t.

    In \woocommerce-gateway-payu-pl\classes\class-payu-rest-api

    In line 72 to 74 you have the following:

    public function get_notify_url( $order ) {
    		if( $order->get_total() == 0 ){
    			return site_url( '?wc-api=WC_Gateway_Payu&rest_api=1&order_id=' . wpdesk_get_order_id( $order ).'&order_type=trial' );
    		}else{
    			return site_url( '?wc-api=WC_Gateway_Payu&rest_api=1&order_id=' . wpdesk_get_order_id( $order ) );
    		}
    	}

    “site_url” retrieves the url based on where the content is located in the server, which is not the best way to retrieve the site’s URL (And yes, the function’s name is kind of deceiving)

    What you might want to use, instead, is “home_url” which is the correct way to retrieve the URL for the site.

    so the code should look like this

    
    public function get_notify_url( $order ) {
    		if( $order->get_total() == 0 ){
    			return home_url( '?wc-api=WC_Gateway_Payu&rest_api=1&order_id=' . wpdesk_get_order_id( $order ).'&order_type=trial' );
    		}else{
    			return home_url( '?wc-api=WC_Gateway_Payu&rest_api=1&order_id=' . wpdesk_get_order_id( $order ) );
    		}
    	}

    As you can see this has nothing to do with WPML per se, but it helps make things compatible. the reason for this, in this specific case is that using site_url will always retrieve the standard site URL entry in the db (instead of the one from home_url which is the one that you should use) and will not be compatible with WPML without custom coding.

    I’m not sure how i can send the “pull request” since i don’t work with SVN hehe but if you let me know how, i can totally send the changes for you.

Viewing 1 replies (of 1 total)
  • Plugin Author PayU GPO

    (@payusa)

    Hi Alejandro,

    woocommerce-gateway-payu-pl is other, non official, commercial plugin.

    • This reply was modified 3 years, 4 months ago by PayU GPO.
Viewing 1 replies (of 1 total)
  • The topic ‘WPML Compatibility’ is closed to new replies.