Restrict characters Vacation Mode Message

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Ultimate Restrict characters Vacation Mode Message

Viewing 16 reply threads
  • Author
    Posts
    • #124052
      Henriette
      Participant

      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.
    • #124097

      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.

    • #124107
      Henriette
      Participant

      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 you

      Attachments:
      You must be logged in to view attached files.
    • #124120

      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.

    • #124133
      Henriette
      Participant

      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.
    • #124198

      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.

    • #124260
      Henriette
      Participant

      I’m sorry but it still isn’t working.
      Please see my attachments and the notes I’ve written on it.

      Thank you

      Attachments:
      You must be logged in to view attached files.
    • #124266
      Henriette
      Participant

      Edit: Updated = Uploaded

    • #124314

      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.

    • #124329
      Henriette
      Participant

      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.

    • #124342
      Henriette
      Participant
      This reply has been marked as private.
    • #124489
      Henriette
      Participant
      This reply has been marked as private.
    • #124535
      This reply has been marked as private.
    • #124592

      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.

    • #124595
      Henriette
      Participant

      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.
      • #124690

        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.

    • #124599
      Henriette
      Participant

      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.

    • #124695
      Henriette
      Participant

      Sorry I missed that.
      Thank you very much for everything!

Viewing 16 reply threads
  • The topic ‘Restrict characters Vacation Mode Message’ is closed to new replies.