Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › Restrict characters Vacation Mode Message
- This topic has 19 replies, 2 voices, and was last updated 4 years, 7 months ago by Henriette.
- AuthorPosts
- April 28, 2020 at 11:28 am #124052HenrietteParticipant
Hi,
I would like to restrict the number of characters vendor can fill in his vacation mode message.
I don’t mind a longer message on his own store page but on store page with all articles from all vendors it looks very disturbing when the vacation message is longer than one line.Also it would be nice if in store list also displays the message when vendor store is in vacation mode.
Now customer has to visit the store first in order to see that that store has vacation.Thank you
Attachments:
You must be logged in to view attached files. - April 28, 2020 at 12:53 pm #124097Sarmistha ChakrabortyMember
Hello,
add_filter('wcfm_vacation_message_text',function($text){ if( did_action( 'woocommerce_after_shop_loop_item' ) || did_action( 'yith_wcqv_product_summary' ) || did_action( 'woocommerce_single_product_lightbox_summary' ) || did_action( 'wc_quick_view_pro_quick_view_product_details' ) ) { $text = wp_trim_words( $text, 10, ' […]' ); } return $text; },20); add_action('woocommerce_after_shop_loop_item','add_msg_to_store_loop_vacation_mode',45); function add_msg_to_store_loop_vacation_mode(){ global $WCFM,$product; if ( is_object( $product ) ) { $vendor_id = wcfm_get_vendor_id_by_post( $product->get_id() ); } $is_marketplace = wcfm_is_marketplace(); $vacation_mode = ''; $vendor_has_vacation = $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability( $vendor_id, 'vacation' ); if ( function_exists( 'wcfm_is_store_page' ) && wcfm_is_store_page() && did_action( 'woocommerce_after_shop_loop_item' ) ) { if( $vendor_has_vacation ) { if( $is_marketplace == 'wcfmmarketplace' ) { $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); $vacation_mode = isset( $vendor_data['wcfm_vacation_mode'] ) ? $vendor_data['wcfm_vacation_mode'] : 'no'; } else { $vacation_mode = ( get_user_meta( $vendor_id, 'wcfm_vacation_mode', true ) ) ? get_user_meta( $vendor_id, 'wcfm_vacation_mode', true ) : 'no'; } } if ( $vacation_mode == 'yes' ) { ?> <div class="wcfm_vacation_msg">On Vacation</div> <?php } } }
Try this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Thanks.
- April 28, 2020 at 1:39 pm #124107HenrietteParticipant
Thank you but that is not what I meant.
Vendor can still add as much text as he wants. The only difference is that on de store it looks like “read more”.
I want vendor to not be able to put in more than say 50 characters. It has to fit on one line. Not more.Also I would like to change the date format of the date picker.
Please see attachments.
Thank youAttachments:
You must be logged in to view attached files. - April 28, 2020 at 2:08 pm #124120Sarmistha ChakrabortyMember
Hello,
Add below script in your theme’s js file (https://developer.wordpress.org/reference/functions/wp_enqueue_script/)
jQuery(document).ready(function ($) { if( $('textarea#wcfm_vacation_mode_msg').length > 0 ) { $('textarea#wcfm_vacation_mode_msg').attr('maxlength', '50'); } /*change date format as per your requirement*/ $( "#wcfm_vacation_start_date" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy', onClose: function( selectedDate ) { $( "#wcfm_vacation_end_date" ).datepicker( "option", "minDate", selectedDate ); } }); $( "#wcfm_vacation_end_date" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy', onClose: function( selectedDate ) { $( "#wcfm_vacation_start_date" ).datepicker( "option", "maxDate", selectedDate ); } }); });
To change date placeholder, add this code in your theme’s functions.php
add_filter( 'wcfm_vendors_settings_fields_vacation', function( $fields,$vendor_id ) { if( isset( $fields['wcfm_vacation_start_date'] ) ) { $fields['wcfm_vacation_start_date']['placeholder'] = __( 'From', 'wc-frontend-manager' ) . ' ... dd-mm-yy'; } if( isset( $fields['wcfm_vacation_end_date'] ) ) { $fields['wcfm_vacation_end_date']['placeholder'] = __( 'To', 'wc-frontend-manager' ) . ' ... dd-mm-yy'; } return $fields; }, 50,2 );
Thanks.
- April 28, 2020 at 2:33 pm #124133HenrietteParticipant
What do you mean by the link you gave me?
I don’t know anything about java.
I also don’t have a js.file in my child theme.
There is a folder in the parent theme but that folder contains a lot of other files.
Please tell me to which file I should add the snippet you gave me.
I don’t even know if it’s possible to override this in my child theme because the parent theme will be overridden at update right?Besides I don’t need the placeholder snippet because unfortunately I had to remove all placeholders because of some hard cored placeholders that can’t be translated by Loco Translate and some of the placeholders which contains the same language strings (see before last message: https://wclovers.com/forums/topic/what-do-this-shipping-fields-mean/).
The date you see in my example is how it looks when vendor chooses a start and end date.Attachments:
You must be logged in to view attached files. - April 28, 2020 at 4:43 pm #124198Sarmistha ChakrabortyMember
Hello,
Add this code in your child theme’s function.php and create custom.js file in your child theme folder
function custom_enqueue(){ //wp_enqueue_style('string $handle', mixed $src, array $deps, mixed $ver, bol $in_footer ); wp_enqueue_script('customjs', get_stylesheet_directory_uri() . '/custom.js', array(), '1.0.0', 'true' ); } add_action('wp_enqueue_scripts', 'custom_enqueue');
Paste the the below script in your custom.js file,
jQuery(document).ready(function ($) { if( $('textarea#wcfm_vacation_mode_msg').length > 0 ) { $('textarea#wcfm_vacation_mode_msg').attr('maxlength', '50'); } /*date format will be 28-04-2020*/ $( "#wcfm_vacation_start_date" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy', onClose: function( selectedDate ) { $( "#wcfm_vacation_end_date" ).datepicker( "option", "minDate", selectedDate ); } }); $( "#wcfm_vacation_end_date" ).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy', onClose: function( selectedDate ) { $( "#wcfm_vacation_start_date" ).datepicker( "option", "maxDate", selectedDate ); } }); });
To remove placehoder –
add_filter( 'wcfm_vendors_settings_fields_vacation', function( $fields,$vendor_id ) { if( isset( $fields['wcfm_vacation_start_date'] ) ) { $fields['wcfm_vacation_start_date']['placeholder'] = ''; } if( isset( $fields['wcfm_vacation_end_date'] ) ) { $fields['wcfm_vacation_end_date']['placeholder'] = ''; } return $fields; }, 50,2 );
Thanks.
- April 28, 2020 at 6:17 pm #124260
- April 28, 2020 at 6:18 pm #124266HenrietteParticipant
Edit: Updated = Uploaded
- April 28, 2020 at 8:28 pm #124314Sarmistha ChakrabortyMember
Hello,
We have checked in our server.This code is working in our server.
Please share us the site admin access, we need check your site.Thanks.
- April 28, 2020 at 8:50 pm #124329HenrietteParticipant
Thank you.
On what e-mail address?
I already made an account for Sushobhan with admin access but I don’t know if I can share that with you.- April 28, 2020 at 9:03 pm #124336Sarmistha ChakrabortyMemberThis reply has been marked as private.
- April 28, 2020 at 9:15 pm #124342HenrietteParticipantThis reply has been marked as private.
- April 28, 2020 at 9:32 pm #124352Sarmistha ChakrabortyMemberThis reply has been marked as private.
- April 29, 2020 at 10:01 am #124489HenrietteParticipantThis reply has been marked as private.
- April 29, 2020 at 12:37 pm #124535Sarmistha ChakrabortyMemberThis reply has been marked as private.
- April 29, 2020 at 3:11 pm #124592Sarmistha ChakrabortyMember
Hello,
We have fixed all php errors.
Please check again the topic requirement, login as a vendor “Restrict characters Vacation Mode Message” requirement.
N.B : We have notices too many codes/functions in your functions.php. please be advised only used those functions/codes which you required.Thanks.
- April 29, 2020 at 3:33 pm #124595HenrietteParticipant
Thank you very much! It’s working now.
N.B : We have notices too many codes/functions in your functions.php. please be advised only used those functions/codes which you required.
Thank you I know.
That’s why I began with commenting them because a lot I do not even know what is is for except for the snippets I got from WCLovers.One more question though.
Would you please consider that maybe in the next update vacation mode is also visible in store list page as in the attached example?
Than the customer doesn’t have to visit the store(s) first in order to see that it is in vacation mode.For now I’m very happy for what you’ve done for me.
Thanks again!Attachments:
You must be logged in to view attached files.- April 29, 2020 at 7:14 pm #124690Sarmistha ChakrabortyMember
Hello,
Would you please consider that maybe in the next update vacation mode is also visible in store list page as in the attached example?
Than the customer doesn’t have to visit the store(s) first in order to see that it is in vacation mode.
>>For this we have provide you code previously.add_action('woocommerce_after_shop_loop_item','add_msg_to_store_loop_vacation_mode',45); function add_msg_to_store_loop_vacation_mode(){ global $WCFM,$product; if ( is_object( $product ) ) { $vendor_id = wcfm_get_vendor_id_by_post( $product->get_id() ); } $is_marketplace = wcfm_is_marketplace(); $vacation_mode = ''; $vendor_has_vacation = $WCFM->wcfm_vendor_support->wcfm_vendor_has_capability( $vendor_id, 'vacation' ); if ( function_exists( 'wcfm_is_store_page' ) && wcfm_is_store_page() && did_action( 'woocommerce_after_shop_loop_item' ) ) { if( $vendor_has_vacation ) { if( $is_marketplace == 'wcfmmarketplace' ) { $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); $vacation_mode = isset( $vendor_data['wcfm_vacation_mode'] ) ? $vendor_data['wcfm_vacation_mode'] : 'no'; } else { $vacation_mode = ( get_user_meta( $vendor_id, 'wcfm_vacation_mode', true ) ) ? get_user_meta( $vendor_id, 'wcfm_vacation_mode', true ) : 'no'; } } if ( $vacation_mode == 'yes' ) { ?> <div class="wcfm_vacation_msg">On Vacation</div> <?php } } }
We have deleted the FTP details post. Your issue is resolved. We are closing this topic.
Thanks.
- April 29, 2020 at 3:35 pm #124599HenrietteParticipant
PS. I think the time has past for me to edit my post with FTP credentials because I can not remove this anymore.
Would you please be so kind to remove this ftp credentials for me if that’s possible?
I know it’s a private post but I don’t like it to stay here that way.
Thank you. - April 29, 2020 at 7:19 pm #124695HenrietteParticipant
Sorry I missed that.
Thank you very much for everything!
- AuthorPosts
- The topic ‘Restrict characters Vacation Mode Message’ is closed to new replies.