He Louise,
Yes i tried it, but it didn’t work as expected, so i ended up rewriting woocommerce myself. Looking at his plugin, it should work, but somehow it didn’t return any url…
What i did in the end was overrule a few functions and added the id’s hardcoded as i was running out of time to complete the project.
The checkout page needs some javascript in order to work, so the function to check if the checkout page is active needs to be altered.
includes wc-conditional-functions.php
function is_checkout() {
$result = false;
if(is_page(52) || is_page(125)){
$result = true;
}
return $result;
//return is_page( wc_get_page_id( 'checkout' ) ) ? true : false;
}
Also, to get the correct url for the checkout or cart page two functions need to be altered.
includes/class-wc-cart.php
public function get_cart_url() {
$cart_page_id = wc_get_page_id( 'cart' );
//we need to know the language
$curLang = get_locale();
//echo "lang: ".$curLang."<br />";
/*
//now get the correct post
$daPost = pll_get_post($page_id, $curLang);
//echo $daPost."<br />";
if($daPost){
$page_id = $daPost;
}
*/
$permalink = get_permalink( $cart_page_id );
if($curLang == 'en_US'){
$cart_page_id == 118;
$permalink = str_replace("51", "118", $permalink);
}
//return apply_filters( 'woocommerce_get_cart_url', $cart_page_id ? get_permalink( $cart_page_id ) : '' );
return apply_filters( 'woocommerce_get_cart_url', $permalink );
}
public function get_checkout_url() {
$checkout_page_id = wc_get_page_id( 'checkout' );
$checkout_url = '';
if ( $checkout_page_id ) {
//we need to know the language
$curLang = get_locale();
//echo "lang: ".$curLang."<br />";
/*
if($curLang == 'en_US'){
$checkout_page_id == 125;
}
*/
if ( is_ssl() || get_option('woocommerce_force_ssl_checkout') == 'yes' ) {
$checkout_url = str_replace( 'http:', 'https:', get_permalink( $checkout_page_id ) );
} else {
$checkout_url = get_permalink( $checkout_page_id );
}
if($curLang == 'en_US'){
$checkout_url = str_replace("52", "125", $checkout_url);
}
}
return apply_filters( 'woocommerce_get_checkout_url', $checkout_url );
}
Hope this will help!