• Resolved mikel555

    (@mikel555)


    Hello, thank you for a great plugin. At least Im facing one issue. How may I get product permalink for weglot?

    In my code Im getting product permalink like this
    $permalink = get_permalink( $item['product_id'] ) ;

    This always retrieves product permalink for the parent language only. How may I get the other languages permalinks translated by weglot? Can you please help?

    Thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter mikel555

    (@mikel555)

    Fixed this way

    $weburl = get_site_url();
    $weglotlanguage = $order->get_meta('weglot_language');
    $product = get_post( $item->get_product_id() );
    $slug = $product->post_name;
    
    echo '<a href="' . $weburl . '/'.$weglotlanguage.'/?product=' . $slug .'#tab-reviews" style="font-size:15px; text-decoration: unset; line-height:50px;">' . $name . '</a><br>';

    But Im still interested if there is some other solution which could get exact slug or permalink from weglot. Thanks

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    hi @mikel555 ,
    I’m Edson from Weglot.
    hope you’re fine? Sorry for the issue you’re facing and I’m glad to help you.

    In fact, the url should be translate automatically by our plugin. Do you have an url I can see why the url isn’t translate ?

    Regards

    Thread Starter mikel555

    (@mikel555)

    Thank you Edson for the answer. I think you did not get the point. Let me explain. I have custom email to get reviews from our customers. In the email I retrieve products they have ordered.

    Example you order in parent language some tshirt. I will retrieve url and guide you to give me review like this – site.com/product/tshirt#tab-reviews

    If you order the same product from other language for example german. It has to be like this – site.com/de/product/GERMAN SLUG FOR PRODUCT#tab-reviews

    My question is how may I retrieve translated slug for product id with php.
    In woocommerce you could do it like this

    Permalink URL
    $permalink = get_permalink( $item['product_id'] ) ;
    Slug
    $slug = $product->post_name;

    So the question is how to get permalink for weglot or slug for weglot if product is already translated and slug is also translated.

    Thanks

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    Hi @mikel555 ,

    ok my bad I guess you takling about link into a page.
    They are 2 ways:
    1- you can send the content of your email to weglot and the link should be translate automatically. You can check here how we translate mail from woocommerce line 76 to 93 : /wp-content/plugins/weglot/src/third/woocommerce/class-wc-mail-weglot.php

    2- you can try use this filter : https://developers.weglot.com/wordpress/filters/other-filters#hook-weglot_translate_email

    Let me know if it’s help you
    Regards

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    Hi @mikel555 ,

    hope you’re fine? Are you still facing your issue or it’s ok ? Don’t hesitate if you need more help

    Regards

    Thread Starter mikel555

    (@mikel555)

    Hello I fixed this. Thank you.
    Facing one extra issue now.

    Is there a possibility to add parent language into slug with weglot?
    Like /en for parent which is not translated with weglot?

    Thanks

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    Hi @mikel555 ,
    you can exclude the url you don’t want to translate on the dashboard. We’ve an option that allow you to exclude a url but you keep the url and have no translation in it.

    Don’t hesitate to contact our support if you need more information (screenshot,…) to do it

    Regards

    Thread Starter mikel555

    (@mikel555)

    Hello, I do not want to exclude.
    As I mentioned above.

    When you use weglot theres a language code after slash in the URL slug like /de, /en, /es…etc

    How about the parent language? Is there any way to set it from website.com to website.com/fr if the parent language is french?

    Thanks

    Plugin Contributor Edson Galina Fortes

    (@glx77)

    hi @mikel555 ,

    ok, I’m sorry it’s not possible to change the original slug with weglot. It may be possible with specific dev but you’s may facing some redirection issue

    Regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Get product permalink in php’ is closed to new replies.