• Hi and thanks for a superb plugin!

    I have Woocommerce installed and noticed
    that when you are on a translated page and click on add to cart.

    You are redirected to the correct page BUT in the default language.

    For example I am att domain.com/sv (for Swedish translation) and then get redirected to https://maskedworkers.com/product/ (without /sv/)

    Could you please help me?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • In transposh_3rdparty.
    in function function __construct(&$transposh) {
    add this filter
    add_filter( ‘woocommerce_add_to_cart_redirect’, array(&$this, ‘rv_redirect_on_add_to_cart’) );
    then after this function add the rv_redirect_on_add_to_cart function
    function rv_redirect_on_add_to_cart($url) {
    if ( isset( $_POST[‘add-to-cart’] ) ) {
    $product_id = (int) apply_filters( ‘woocommerce_add_to_cart_product_id’, $_POST[‘add-to-cart’] );
    $urle = get_permalink($product_id); // URL to redirect to (1 is the page ID here)
    $lang = transposh_utils::get_language_from_url($_SERVER[‘HTTP_REFERER’], $this->transposh->home_url);
    tp_logger(‘altering woo url to:’ . transposh_utils::rewrite_url_lang_param($urle, $this->transposh->home_url, $this->transposh->enable_permalinks_rewrite, $lang, $this->transposh->edit_mode));
    return transposh_utils::rewrite_url_lang_param($urle, $this->transposh->home_url, $this->transposh->enable_permalinks_rewrite, $lang, $this->transposh->edit_mode);
    }
    }

    Also in the function function __construct(&$transposh) {
    these lines will help to get the correct url for woocommerce special page
    add_filter(‘woocommerce_get_checkout_url’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_get_cart_url’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_get_checkout_order_received_url’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_get_checkout_payment_url’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_get_myaccount_page_permalink’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_cart_item_permalink’, array(&$this, ‘woo_uri_filter’));
    add_filter(‘woocommerce_get_cart_page_permalink’, array(&$this, ‘woo_uri_filter’));

    Hello, I’m with rhe same problem here i added the code but i get SYNTAX ERROR unexpected TString , or ) here:

    tp_logger(‘altering woo url to:’ . transposh_utils::rewrite_url_lang_param($urle, $this->transposh->home_url, $this->transposh->enable_permalinks_rewrite, $lang, $this->transposh->edit_mode));

    Can you please see if that is wrong?

    Thank you

    First of all, thanks for the plugin, it’s awesome. But with WooCommerce the problem was not solved. Нere (https://dropover.cloud/323f66) is some of the code, pasted in as you recommended. Does not work. Is there a mistake here?
    Thanks in advance

    Roryrory, thank you so much for the help and for the simple explanation.
    P.S. For those people who report a Syntax error, please check that the quotes have not been edited when copying/pasting the code.

    Also, please, what is the best way to also correct class-wc-structured-data and breadcrumb, so that on google structured data test the description and url, refer to the translated page?
    Thanks in advance

    hi, I have a some problem here…
    May i know how to solve it?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Woocommerce add to cart button redirects to default language.’ is closed to new replies.