How to use a different template based on some order variable?
-
Tell me please. How can I check the payment method? And where should I put this code?
/**
* Change template based on WPML order language.
* Make sure to create custom templates with the correct names or the templates won’t be found.
*
* @param string $template_name template name.
* @param string $template_type template type like global or simple.
* @param int $order_id WC Order ID.
*
* @return string
*/
function change_template_based_on_order_language( $template_name, $template_type, $order_id ) {
$order_language = get_post_meta( $order_id, ‘wpml_language’, true );if ( false === $order_language ) {
return $template_name;
}switch ( $order_language ) {
case ‘en’:
$template_name = ‘minimal-en’;
break;
case ‘nl’:
$template_name = ‘minimal-nl’;
break;
}return $template_name;
}
add_filter( ‘wpi_template_name’, ‘change_template_based_on_order_language’, 10, 3 );`
- The topic ‘How to use a different template based on some order variable?’ is closed to new replies.