Reply To: Widget calendar and form not loading correct resource in WPML

Hi,

well, I see what you are saying, and be that as it may, the IDs between a resource and the booking form must match. Since on the widget form the select field will be selected only if the form can match the populated field IDs with the ID of the currently displayed resource. Since form has values from the default language, and current resource (if not the default language) has its own ID that does not match, the calendar does not display the proper resource, the select field does not automatically select the currently displayed resource, and when user clicks “Book now”, the booking form displays the incorrect resource and price calculation. So, the ID here does matter to me.

NOTE: Okay, so I reverted the function I changed due to your suggestion, and in form_widget.php I changed lines after line 24 into following:

$default_lang_id = icl_object_id($post->ID,'easy-rooms', $post->ID, $default_lang);
if(array_key_exists($default_lang_id, $the_rooms_array)) $calendar_room = $default_lang_id;

This way, my calendar now loads the default language ID, and can match it to the default ID that gets printed by the function easyreservations_resource_options. And voila, the select field is now automatically selected with the currently displayed resource (in default language), no matter what the language version is.