Change back to store URL for all languages ​​with WPML plugin

In my WooCommerce web store, I would like to change the Return to shop URL to a custom URL. I tried using the code below in function.phpmy active topic file , but it does not work.

On my website I have five active languages ​​that are controlled by the WPML commercial plugin. He also runs a script that ensures that visitors from these countries are redirected to their native language.

/**
 * Changes Return to Shop button URL on Cart page.
 *
 */

function wc_empty_cart_redirect_url() {
        return 'http://pacsymposium.com/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );

How can I get this work to get a link to the current language?

Thank.

+4
source share
1

Update2: :

( ).

, :

add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
function wc_empty_cart_redirect_url() {

    // Getting the shop ID
    $shop_id = wc_get_page_id( 'shop' );

    // Getting the current language ID for the shop page
    $current_lang_id = apply_filters( 'wpml_object_id', $shop_id, 'page', TRUE );

    // Getting the post object for the ID
    $post = get_post($current_lang_id);

    // Getting the slug from this post object
    $slug = $post->post_name;

    // We re-use wc_get_page_permalink() function just like in this hook
    $link = wc_get_page_permalink( $slug );

    return  $link;
}

function.php ( ), .

, ...

+4

Source: https://habr.com/ru/post/1669723/


All Articles