Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › Ask a Question Button
Tagged: ask a question button, inquiry button, inquiry tab
- This topic has 20 replies, 7 voices, and was last updated 3 years, 8 months ago by van.vince2.
- AuthorPosts
- July 31, 2019 at 1:35 pm #74608@TravellersIDParticipant
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. - August 2, 2019 at 10:02 pm #74881vanilladev89Participant
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
- August 3, 2019 at 7:32 am #74978WCFM ForumKeymaster
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
- August 4, 2019 at 6:44 am #75119@TravellersIDParticipant
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.
- August 5, 2019 at 12:59 pm #75320WCFM ForumKeymaster
OK, do you want disable “Sold By” from products?
- April 15, 2020 at 3:21 pm #119338karl ohinParticipant
Hi
Is there a method or way to disable the ask a Question from individual product s?
Thanks
- April 16, 2020 at 1:10 pm #119667Sarmistha ChakrabortyKeymaster
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.
- April 16, 2020 at 2:34 pm #119703karl ohinParticipantThis reply has been marked as private.
- April 16, 2020 at 2:37 pm #119705Sarmistha ChakrabortyKeymaster
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.
- April 16, 2020 at 2:42 pm #119707karl ohinParticipant
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
- April 16, 2020 at 3:00 pm #119710Sarmistha ChakrabortyKeymaster
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.
- April 15, 2020 at 4:53 pm #119357pisidiaParticipant
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?
- April 16, 2020 at 1:13 pm #119668Sarmistha ChakrabortyKeymaster
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> <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.
- April 16, 2020 at 3:08 pm #119713karl ohinParticipant
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
- April 16, 2020 at 5:45 pm #119762Sarmistha ChakrabortyKeymaster
Hi,
It should be
if($product_id == 422 || $product_id == 333 || $product_id == 222 ) {
Thanks.
- April 17, 2020 at 2:52 am #119892pisidiaParticipant
Thank you too, Sarmistha. Your code worked perfectly!
- April 20, 2020 at 8:42 pm #121054Sarmistha ChakrabortyKeymaster
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. - April 22, 2020 at 1:04 am #121514pisidiaParticipant
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?- April 22, 2020 at 1:26 pm #121675Sarmistha ChakrabortyKeymaster
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> <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.
- April 24, 2020 at 8:35 pm #122596pisidiaParticipant
This worked perfectly with a little modification, @Sarmistha – Brilliant, and thank you!!
- July 24, 2020 at 2:15 pm #155257van.vince2Participant
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.
- AuthorPosts
- You must be logged in to reply to this topic.