Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/100018fefa1c30453523 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/100018fefa1c30453523 to your computer and use it in GitHub Desktop.
Adjust the url specified in WooCommerce function get_checkout_order_received_url() so that the correct thankyou page set in WPML is used. // From version 2.4.5 of the DIBS plugin this code is no longer needed. The plugin now have built in support for redirecting to the correct page if using WPML.
<?php
/*
Plugin Name: Correct thankyou page for DIBS/WPML
Plugin URI: http://krokedil.com
Description: Adjust the url specified in WooCommerce function get_checkout_order_received_url() so that the correct thankyou page set in WPML is used.
Version: 1.0
Author: Krokedil
Author URI: http://krokedil.com
*/
// From version 2.4.5 of the DIBS plugin this code is no longer needed. The plugin now have built in support for redirecting to the correct page if using WPML.
add_filter( 'woocommerce_get_checkout_order_received_url', 'krokedil_modify_thankyou_page', 10, 2 );
function krokedil_modify_thankyou_page( $order_received_url, $order ) {
$lang = get_post_meta( $order->id, 'wpml_language', true );
if(isset($lang) && 'sv' == $lang ) {
$default_checkout_id = wc_get_page_id( 'checkout' );
$lang_post_id = icl_object_id( $default_checkout_id , 'page', true, $lang );
$order_received_url = wc_get_endpoint_url( 'order-received', $order->id, get_permalink($lang_post_id) );
$order_received_url = add_query_arg( 'key', $order->order_key, $order_received_url );
}
return $order_received_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment