Support » Plugin: WooCommerce PayU EU Payment Gateway » WPML Compatibility

  • Resolved Alejandro

    (@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

    (@payusa)

    Hi Alejandro,

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

    • This reply was modified 4 months, 2 weeks ago by PayU.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.