Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Adding Timezone dropdown to vendor settings page
- This topic has 11 replies, 3 voices, and was last updated 4 years, 10 months ago by Eden Brownlee.
- AuthorPosts
- October 31, 2019 at 9:58 pm #89959meParticipant
I’ve been trying to implement a Timezone setting for vendors, but I need some help with it.
I have summarized what I have done so far below, but I’m open to any solution that lets vendors set and save their timezones.
Can you help me on how to do that in any way?First, I tried placing it in general settings, like this:
add_filter ( 'wcfm_marketplace_settings_fields_general', 'add_vendor_timezone_setting', 20 ); function add_vendor_timezone_setting($settings_fields_general){ $vendor_id = $settings_fields_general['vendor_id']['value']; $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if( !$vendor_data ) $vendor_data = array(); $timezone_list = DateTimeZone::listIdentifiers(DateTimeZone::ALL); $vendor_timezone = isset( $vendor_data['timezone'] ) ? $vendor_data['timezone'] : ''; $settings_fields_general['timezone']= array( 'label' => __( 'Timezone', 'wc-frontend-manager' ), 'type' => 'select', 'options' => $timezone_list, 'priority' => 50, 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele', 'value' => $vendor_timezone, ); return $settings_fields_general; } add_action( 'wcfm_vendor_settings_update', function( $vendor_id, $wcfm_settings_form ) { global $WCFM, $WCFMmp; if( isset( $wcfm_settings_form['timezone'] ) ) { update_user_meta( get_current_user_id(), 'vendor_timezone', $wcfm_settings_form['timezone'] ); } }, 500, 2 );
If I do this, strangely it creates TWO dropdowns on the same page. (see screenshot)
Also, saving the data doesn’t work at all.I also tried putting the dropdown on a separate tab, and using AJAX for saving:
(js)
$(document).on('click', '#wcfm_settings_save_button', function (e) { e.preventDefault(); var user_timezone = jQuery('#vendor-timezone').val(); if ( user_timezone !== "" ) { jQuery.post( ajaxurl, { 'action': 'update_vendor_timezone', 'user_timezone': user_timezone, }, function(response) { alert(response); } ); } });
(php)
add_action('wp_ajax_update_vendor_timezone', 'update_vendor_timezone'); function update_vendor_timezone(){ if(isset($_POST['user_timezone'])){ update_user_meta(get_current_user_id(), 'vendor-timezone', $_POST['user_timezone']); } die(); }
Thanks a lot for your help in advance.
Attachments:
You must be logged in to view attached files. - November 11, 2019 at 6:54 am #91745Eden BrownleeParticipant
Is anything happening on this, we really need this feature too so that appointments/bookings made with WCFM appear in shopper/user timezone (we use bookingWP), and that vendors can set availability for booking in their own timezone (and set that).
Please help!
- November 11, 2019 at 9:10 pm #91855meParticipant
Hi Eden,
I have good news, I managed to get this done. The part discussed here is pretty straight-forward, things get tricky on the other side with wc-appointments.
I’ll give you the code for the Timezone dropdown inside WCFM Vendor Settings, and we can discuss the rest in the BookingWP forum.
Let me know how it works for you!add_action( 'end_wcfm_marketplace_settings', 'wcfm_vendor_timezone_settings' ); function wcfm_vendor_timezone_settings() { global $WCFM, $WCFMu; ?> <div class="page_collapsible" id="wcfm_settings_form_timezone_head"><label class="wcfmfa fa-clock"></label> <?php _e('Timezone', 'wc-frontend-manager-ultimate'); ?> <span></span></div> <div class="wcfm-container"> <div id="wcfm_settings_form_timezone_expander" class="wcfm-content"> <div class="wcfm-content"> <p class="wcfm_title"><strong> <?php _e('Select your timezone', 'wc-frontend-manager-ultimate'); ?> </strong> <span class="img_tip wcfmfa fa-question" data-tip="This is important for clients outside your timezone." data-hasqtip="23" aria-describedby="qtip-23"> </span> </p> <select id="spiral-vendor-timezone" name="spiral-vendor-timezone"> <?php $timezone_list = DateTimeZone::listIdentifiers(DateTimeZone::ALL); $user_data = get_user_meta( get_current_user_id(), 'wcfmmp_profile_settings', true ); if( !$user_data ) $user_data = array(); $user_timezone = isset( $user_data['spiral-vendor-timezone'] ) ? $user_data['spiral-vendor-timezone'] : ''; foreach($timezone_list as $key => $val) { if ($user_timezone==$val) { echo '<option selected value="' . $val . '" >' . $val . '</option>'; } else { echo '<option value="' . $val . '">' . $val . '</option>'; } } ?> </select> <br><br><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Experimental feature </div></div> </div> <?php }
- November 18, 2019 at 9:18 am #92706Eden BrownleeParticipant
Hi ME, we are now looking to implement this shortly.
Did you happen to send the plugin (per last request from bookingWP)
- November 23, 2019 at 10:09 am #93533WCFM ForumMember
We are working on this.
Well, this may cause other issues, so we are not released this!
- November 25, 2019 at 4:19 am #93807Eden BrownleeParticipant
WCFM, Any update on this?
Would it be possible to even get this as a beta option added to core, and just let us know how to turn it on? This would be great if we can get it rolled out into release and just enable it as a setting. We can test it for you and let you know if we experience any issues.
- December 5, 2019 at 5:47 am #96106Eden BrownleeParticipant
Hi WCFM,
Can we get a response on this? Can we get this added to core? (Again, even as a hidden beta feature so we do not have to edit core files and can continue to update wcfm etc)
- December 7, 2019 at 1:59 pm #96431WCFM ForumMember
Well, we have prepared that code.
But, this setting is not enough to make this working. We have to show all dates in vendor dashboard according to this timezone setting!
- December 10, 2019 at 7:14 am #96812Eden BrownleeParticipant
Is there an ETA on this? Surely it would not be too difficult to update current function to use the timezone setting? 🙂 I hope we can get this actioned sometime in the near future 😀
- December 12, 2019 at 9:06 am #97159WCFM ForumMember
Our team is working on this. Will update you soon.
- December 12, 2019 at 10:05 am #97187Eden BrownleeParticipant
Awesome thanks so much 🙂 looking forward to hearing back from you guys! 🙂
- February 4, 2020 at 5:58 am #105288Eden BrownleeParticipant
Hey there guys, another couple months down, any progress in rolling this out? 🙂 Really need this asap as core hacks are not cool 😀
- AuthorPosts
- The topic ‘Adding Timezone dropdown to vendor settings page’ is closed to new replies.