Ask a Question Button

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!

Viewing 11 reply threads
  • Author
    Posts
    • #74608
      @TravellersID
      Participant

      Hi,

      As I remember, the Ask a Question button is located inside the Inquiries tab in single product page. But now I can’t find it there and have to use shortcode to display it somewhere else. Is there a way to make that button showing inside that tab again?

      Attachments:
      You must be logged in to view attached files.
    • #74881
      vanilladev89
      Participant

      Hey There

      The funny part about this question is that I am still trying to figure out why we can’t have it on both. I mean why is there not an ask a question button on the store page and an inquiry button in the tab where you are asking for it? I don’t know but it’s been a hot topic around the forum for some time and eventually they streamlined it by making it only on the store page. I asked for the same thing you did and this is the code snippet they sent me.

      add_filter( ‘wcfm_is_pref_enquiry_button’, ‘__return_false’ );

      Hope this helped.

      Cheers

    • #74978
      WCFM Forum
      Keymaster

      Right, that setting option is now deprecated.

      It can be possible using this filter –

      add_filter( 'wcfm_is_pref_enquiry_button', '__return_false' );

      Add 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/

      Thank You

    • #75119
      @TravellersID
      Participant

      Hi guys,

      Thank you, the code works! I only need the button in single product since I’m not using vendor store page at the moment.

    • #75320
      WCFM Forum
      Keymaster

      OK, do you want disable “Sold By” from products?

    • #119338
      karl ohin
      Participant

      Hi

      Is there a method or way to disable the ask a Question from individual product s?

      Thanks

      • #119667

        Hello,

        Add 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/

        add_action('init','remove_enquiry_pos');
        function remove_enquiry_pos() {
        	global $WCFM;	
        	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 15);
        	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 25);
        	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 35);
        }

        Thanks.

        • #119703
          karl ohin
          Participant
          This reply has been marked as private.
          • #119705

            Hello,

            Sorry, but have to write this code,

            add_action('init','remove_enquiry_pos');
            function remove_enquiry_pos() {
            	global $WCFM;	
            	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 15);
            	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 25);
            	remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 35);
            }

            Please don’t replace the priority with the “product id”.

            Thanks.

            • #119707
              karl ohin
              Participant

              Hi,

              Sorry about that .

              How do i control the individual product ?

              So if i want just the 422 product to not show the button where is that controlled from ?

              many thanks

              • #119710

                Hi,

                Try this code,

                add_action('woocommerce_single_product_summary','remove_enquiry_pos',10);
                function remove_enquiry_pos() {
                	global $WCFM,$product;
                	$product_id = $product->get_id();
                	if($product_id == 422 ) {
                		remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 15);
                		remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 25);
                		remove_action('woocommerce_single_product_summary', array( $WCFM->wcfm_enquiry, 'wcfm_enquiry_button' ), 35);
                	}
                }

                Thanks.

    • #119357
      pisidia
      Participant

      Hi Guys,

      I’m not sure if I should open a new thread for this, but this is my question:

      Is it possible to have the “Ask A Question” button:
      1. In the shop loop, with the button being under every product
      2. Button only available to specific user ROLE (for example, only ‘wholesaler’ user role can see this button)

      The way the button functions is perfect, with how it opens a popup form. And the form itself is perfect too. Is it easily possible to have this button in the Shop loop?

      • #119668

        Hello,

        To show “Ask a question” button n shop page only for “wholesaler” role,

        add_action('woocommerce_after_shop_loop_item','shoploop_wcfm_enquiry_button', 9 );
        function shoploop_wcfm_enquiry_button(){
        	global $product;
        	$product_id = $product->get_id();
        	$vendor_id   = wcfm_get_vendor_id_by_post( $product_id );	
        	$button_style     = 'margin-right:10px;';
        	$hover_color      = '';
        	$hover_text_color = '#ffffff';
        	$wcfm_options = $WCFM->wcfm_options;
        	$wcfm_store_color_settings = get_option( 'wcfm_store_color_settings', array() );
        	if( !empty( $wcfm_store_color_settings ) ) {
        		if( isset( $wcfm_store_color_settings['button_bg'] ) ) { $button_style .= 'background: ' . $wcfm_store_color_settings['button_bg'] . ';border-bottom-color: ' . $wcfm_store_color_settings['button_bg'] . ';'; }
        		if( isset( $wcfm_store_color_settings['button_text'] ) ) { $button_style .= 'color: ' . $wcfm_store_color_settings['button_text'] . ';'; }
        		if( isset( $wcfm_store_color_settings['button_active_bg'] ) ) { $hover_color = $wcfm_store_color_settings['button_active_bg']; }
        		if( isset( $wcfm_store_color_settings['button_active_text'] ) ) { $hover_text_color = $wcfm_store_color_settings['button_active_text']; }
        	} else {
        		if( isset( $wcfm_options['wc_frontend_manager_button_background_color_settings'] ) ) { $button_style .= 'background: ' . $wcfm_options['wc_frontend_manager_button_background_color_settings'] . ';border-bottom-color: ' . $wcfm_options['wc_frontend_manager_button_background_color_settings'] . ';'; }
        		if( isset( $wcfm_options['wc_frontend_manager_button_text_color_settings'] ) ) { $button_style .= 'color: ' . $wcfm_options['wc_frontend_manager_button_text_color_settings'] . ';'; }
        		if( isset( $wcfm_options['wc_frontend_manager_base_highlight_color_settings'] ) ) { $hover_color = $wcfm_options['wc_frontend_manager_base_highlight_color_settings']; }
        	}	
        	$wcfm_enquiry_button_label  = isset( $wcfm_options['wcfm_enquiry_button_label'] ) ? $wcfm_options['wcfm_enquiry_button_label'] : __( 'Ask a Question', 'wc-frontend-manager' );	
        	$button_class = '';
        	if( !is_user_logged_in() && apply_filters( 'wcfm_is_allow_enquiry_with_login', false ) ) { $button_class = ' wcfm_login_popup'; }
        	if( is_user_logged_in()) {
        		$user = wp_get_current_user();
                        //replace the "wholesaler" role with your required role
        		if ( in_array( 'wholesaler', (array) $user->roles ) ) {
        	?>
        		<div class="wcfm_ele_wrapper wcfm_catalog_enquiry_button_wrapper">
        			<div class="wcfm-clearfix"></div>
        			<a href="#" class="wcfm_catalog_enquiry <?php echo $button_class; ?>" data-store="<?php echo $vendor_id; ?>" data-product="<?php echo $product_id; ?>" style="<?php echo $button_style; ?>"><span class="wcfmfa fa-question-circle"></span>&nbsp;&nbsp;<span class="add_enquiry_label"><?php _e( $wcfm_enquiry_button_label, 'wc-frontend-manager' ); ?></span></a>
        			<?php do_action( 'wcfm_after_product_catalog_enquiry_button' ); ?>
        			<?php if( $hover_color ) { ?>
        				<style>
        				a.wcfm_catalog_enquiry:hover{background: <?php echo $hover_color; ?> !important;background-color: <?php echo $hover_color; ?> !important;border-bottom-color: <?php echo $hover_color; ?> !important;color: <?php echo $hover_text_color; ?> !important;}
        				</style>
        			<?php } ?>
        			<div class="wcfm-clearfix"></div>
        		</div>
        	<?php
        		}
        	}
        }

        Add 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.

      • #119713
        karl ohin
        Participant

        Thanks that worked perfect

        So i have a few products where i want to do this will i put

        
        if($product_id == 422 && 333 && 222 ) {
        
        

        Thanks for the help

        • #119762

          Hi,

          It should be
          if($product_id == 422 || $product_id == 333 || $product_id == 222 ) {

          Thanks.

    • #119892
      pisidia
      Participant

      Thank you too, Sarmistha. Your code worked perfectly!

    • #121054

      You are always welcome 🙂

      Let me know if there’s anything else we can help you with.
      Can we ask for a favor? Would you mind taking a few minutes to review our plugin at https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/ and let others know about your 5 Star experience with WCFM Marketplace. Also, follow us on Twitter https://twitter.com/wcfmmp for more exciting news, important updates, and irresistible offers.

    • #121514
      pisidia
      Participant

      Hi @Sarmistha!

      So one more question on the Inquiry button. The code you sent has worked out perfectly, and the wholesaler role is able to send inquiry for product, right from the shop loop. Perfect!

      My question now is: Is it easily possible to show the product inquiry button differently, IF the currently logged in wholesaler has sent an inquiry on the product before?

      So something like:

      IF the currently logged in wholesaler role has never sent an inquiry on this product {
      show the button just as you have sent it, in the shop loop;
      } else {
      // if the currently logged in wholesaler has already sent an inquiry before on this specific product
      show a different style button; (the button will function just the same, but wholesaler will have a visual cue that (s)he sent inquiry before)
      }


      Is this possible?

      • #121675

        Hi,

        What you can do display a message before “Ask a Question” button to modify the previous code,

        add_action('woocommerce_after_shop_loop_item','shoploop_wcfm_enquiry_button', 9 );
        function shoploop_wcfm_enquiry_button(){
        	global $product,$wpdb;
        	$product_id = $product->get_id();
        	$vendor_id   = wcfm_get_vendor_id_by_post( $product_id );	
        	$button_style     = 'margin-right:10px;';
        	$hover_color      = '';
        	$hover_text_color = '#ffffff';
        	$wcfm_options = $WCFM->wcfm_options;
        	$wcfm_store_color_settings = get_option( 'wcfm_store_color_settings', array() );
        	if( !empty( $wcfm_store_color_settings ) ) {
        		if( isset( $wcfm_store_color_settings['button_bg'] ) ) { $button_style .= 'background: ' . $wcfm_store_color_settings['button_bg'] . ';border-bottom-color: ' . $wcfm_store_color_settings['button_bg'] . ';'; }
        		if( isset( $wcfm_store_color_settings['button_text'] ) ) { $button_style .= 'color: ' . $wcfm_store_color_settings['button_text'] . ';'; }
        		if( isset( $wcfm_store_color_settings['button_active_bg'] ) ) { $hover_color = $wcfm_store_color_settings['button_active_bg']; }
        		if( isset( $wcfm_store_color_settings['button_active_text'] ) ) { $hover_text_color = $wcfm_store_color_settings['button_active_text']; }
        	} else {
        		if( isset( $wcfm_options['wc_frontend_manager_button_background_color_settings'] ) ) { $button_style .= 'background: ' . $wcfm_options['wc_frontend_manager_button_background_color_settings'] . ';border-bottom-color: ' . $wcfm_options['wc_frontend_manager_button_background_color_settings'] . ';'; }
        		if( isset( $wcfm_options['wc_frontend_manager_button_text_color_settings'] ) ) { $button_style .= 'color: ' . $wcfm_options['wc_frontend_manager_button_text_color_settings'] . ';'; }
        		if( isset( $wcfm_options['wc_frontend_manager_base_highlight_color_settings'] ) ) { $hover_color = $wcfm_options['wc_frontend_manager_base_highlight_color_settings']; }
        	}	
        	$wcfm_enquiry_button_label  = isset( $wcfm_options['wcfm_enquiry_button_label'] ) ? $wcfm_options['wcfm_enquiry_button_label'] : __( 'Ask a Question', 'wc-frontend-manager' );	
        	$button_class = '';
        	if( !is_user_logged_in() && apply_filters( 'wcfm_is_allow_enquiry_with_login', false ) ) { $button_class = ' wcfm_login_popup'; }
        	if( is_user_logged_in()) {
        		$user = wp_get_current_user();
                        //replace the "wholesaler" role with your required role
        		if ( in_array( 'wholesaler', (array) $user->roles ) ) {
        	?>
        		<div class="wcfm_ele_wrapper wcfm_catalog_enquiry_button_wrapper">
        			<div class="wcfm-clearfix"></div>
        			<?php
        			$table_name = $wpdb->prefix . "wcfm_enquiries";
        			$current_user_id = get_current_user_id();
        	  		$have_enquiry = $wpdb->get_results( "SELECT * FROM $table_name WHERE <code>product_id</code>=$product_id AND <code>customer_id</code>=$current_user_id" );
        	  		
        	  		if(!empty($have_enquiry)) {
        	  			echo '<p style="clear:both">'.__('You have sent inquiry before','wc-frontend-manager').'</p>';
        	  		} ?>
        			<a href="#" class="wcfm_catalog_enquiry <?php echo $button_class; ?>" data-store="<?php echo $vendor_id; ?>" data-product="<?php echo $product_id; ?>" style="<?php echo $button_style; ?>"><span class="wcfmfa fa-question-circle"></span>&nbsp;&nbsp;<span class="add_enquiry_label"><?php _e( $wcfm_enquiry_button_label, 'wc-frontend-manager' ); ?></span></a>
        			<?php do_action( 'wcfm_after_product_catalog_enquiry_button' ); ?>
        			<?php if( $hover_color ) { ?>
        				<style>
        				a.wcfm_catalog_enquiry:hover{background: <?php echo $hover_color; ?> !important;background-color: <?php echo $hover_color; ?> !important;border-bottom-color: <?php echo $hover_color; ?> !important;color: <?php echo $hover_text_color; ?> !important;}
        				</style>
        			<?php } ?>
        			<div class="wcfm-clearfix"></div>
        		</div>
        	<?php
        		}
        	}
        }

        Thanks.

    • #122596
      pisidia
      Participant

      This worked perfectly with a little modification, @Sarmistha – Brilliant, and thank you!!

    • #155257
      van.vince2
      Participant

      Please i wan to make the “ask question button” display “contact supplier” and make the inquiry popup display the contact details (say numbers) of certain vendors.

Viewing 11 reply threads
  • You must be logged in to reply to this topic.