KLicheR / wp-polylang-translate-rewrite-slugs

Wordpress plugin to help translate post types rewrite slugs with the Polylang plugin.
110 stars 45 forks source link

My snippets which can be helpful to create Polylang & WooCommerce Integration Plugin #17

Open rootkowsky opened 9 years ago

rootkowsky commented 9 years ago

Hi, I've discovered this plugin yesterday. Amazing work. I spend few hours to translate own shop with Polylang plugin, because there were problems with shop (archive product) routing. Your plugin of course solves it. I want to become helpful and place here my snippets which can be usefull to create Polylang & WooCommerce Integration Plugin.

/* WOOCOMMERCE AND POLYLANG INTEGRATION */

/* Woocommerce Login Redirect */
add_filter('woocommerce_login_redirect', 'wi_login_redirect');
function wi_login_redirect( $redirect_to ) {
    if(function_exists('pll_get_post')){
        return get_permalink(pll_get_post(url_to_postid( $redirect_to )));
    }
    return $redirect_to;
}

/* Woocommerce PolyLang Proper Woocommerce Pages Routing */
add_filter('woocommerce_get_shop_page_id','pll_woocommerce_get_page_id');
add_filter('woocommerce_get_cart_page_id','pll_woocommerce_get_page_id');
add_filter('woocommerce_get_checkout_page_id','pll_woocommerce_get_page_id');
add_filter('woocommerce_get_terms_page_id','pll_woocommerce_get_page_id');
add_filter('woocommerce_get_myaccount_page_id','pll_woocommerce_get_page_id');
function pll_woocommerce_get_page_id($id){
    if(function_exists('pll_get_post')){
        return pll_get_post($id);
    }
    return $id;
}
optiguy commented 9 years ago

Thanks for the snippet. I only had two of the pages in my own plugin, so this helped me a lot :)