Ready to get started?Download WordPress


Easy Digital Downloads
[resolved] checkout url on multilingual site (12 posts)

  1. Piet
    Posted 1 year ago #

    Hi Pippin,

    I am experiencing some trouble with getting (to) the correct checkout url on a site made multilingual with WPML.

    I had a look through the code of the template-functions.php and on line 64 I saw where it gets the url from:
    $checkout_url = get_permalink( $edd_options['purchase_page'] );

    Then I went made a WPML Language Configuration File (http://wpml.org/documentation/support/language-configuration-files/) and added that option to it. In the WPML backend I can "translate" the output of that option, which is a Page_ID.

    Now I have tried "translating" this with the page_IDs of the checkout pages of the other languages, as well as with the whole URL of those checkout pages, however the plugin does not pick up on it.

    I have also tried hardcoding a WPML compatible string into the plugin, if only to see if that would help, but also that does not give the desired effect.
    Such a string looks like this:

    $checkout_url = get_permalink( icl_object_id( 4, 'page', true ) );
    where 4 is the Page_ID of the English Checkout Page

    Basically I can only get the checkout (and the following purchase confirmation) to work on the default (English) language, not on any of the other languages.

    Do you have/know of any solution for this?



  2. Piet,

    The part that you changed is specific to the add to cart buttons, and will not affect the 'Checkout' link shown in the cart widget or anywhere else.

    Take a look at edd_get_checkout_uri() in cart-functions.php and try changing it there.

    The edd_get_checkout_uri() is the function used globally for retrieving the URL of the checkout page, so that is where you will probably want to change it.

    Does that help?

  3. Piet
    Posted 1 year ago #

    Hi Pippin,
    Thanks for your reply.
    I suppose I could change it there, but once your plugin receives an update those changes will be lost.
    Is there a way to conserve those changes for the future?

  4. Change it to what is shown here: https://github.com/pippinsplugins/Easy-Digital-Downloads/blob/master/includes/cart-functions.php#L419

    Then make your changes via a filter. Are you familiar with filters?

  5. Piet
    Posted 1 year ago #

    ok, I assume that will be the same in the next update then?

    didn't you just post an article on tutsplus about "Writing Extensible Plugins With Actions and Filters"?

    Would it be sth like this?

    function pb_modify_checkout_uri( $uri ) {
        $uri = icl_object_id( 4, 'page', true);
        return $uri;
    add_filter( 'edd_get_checkout_uri', 'pb_modify_checkout_uri' );

    And I probably will have to add such a filter for both this link as well as the purchase confirmation link, correct?


  6. Piet
    Posted 1 year ago #

    the above code also needs the get_permalink() part, so the actual code becomes:

    // Add filter to Easy Digital Downloads plugin to internationalize purchase page string
    function pb_modify_checkout_uri( $uri ) {
        $uri = get_permalink( icl_object_id( 4, 'page', true) );
        return $uri;
    add_filter( 'edd_get_checkout_uri', 'pb_modify_checkout_uri' );

    where 4 is the purchase page of the default language

    I have also added a filter to the edd_success_page_redirect:

    // Add filter to Easy Digital Downloads plugin to internationalize success page string
    function pb_modify_success_redirect( $redirect ) {
    	$redirect = get_permalink( icl_object_id( 863, 'page', true) );
    	return $redirect;
    add_filter( 'edd_success_page_redirect', 'pb_modify_success_redirect' );

    where 863 is the success page of the default language

    Do I need to add more of these filters or will these two suffice?

  7. Yes I did just post that article :)

    Your last two filters look great.

  8. Piet
    Posted 1 year ago #

    cool, thanks so much for the support!

  9. David from WPML has been looking into this, and this is what he had to say:

    All this shouldn't be necesary if you enable 'Adjust IDs for multilingual functionality' in WPML -> Languages. This is enabled by default

  10. Piet
    Posted 1 year ago #

    I don't agree with this. I always leave that default option on, but without the filters I am unable to make it work.

  11. Having not used WPML personally, I cannot attest to what David said, simply that that is what he told me.

  12. Piet
    Posted 1 year ago #

    Yes, I understand that Pippin. I will email him directly.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic