How can Vendors add a Custom Tab in Product page

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 5 reply threads
  • Author
    Posts
    • #132801
      delwyn
      Participant

      Hi,

      Is there anyway Vendors can add a custom tab at the product page?

      (See ATTACHED IMAGE)

      I want to allow vendors to add a “Delivery” tab the product page.

      This is because different vendors have different delivery schedule.

      Please help.

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

      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_filter( 'woocommerce_product_tabs', 'wcfm_product_delivert_tabs', 100, 1 );
      function wcfm_product_delivert_tabs( $tabs ) {
      
      	$tabs['wcfm_product_delivert_tab'] = apply_filters( 'wcfm_product_delivert_tab_element',array(
      																																								'title' 	=>  __( 'Delivery', 'woocommerce' ),
      																																								'priority' 	=> 55,
      																																								'callback' 	=> 'wcfm_delivery_product_tab_content'
      																																							) );
      	$prod_id = get_the_ID();
      	$vendor_id   = wcfm_get_vendor_id_by_post( $prod_id );
      	$vendor_delvery_schedules = get_user_meta($vendor_id,'wcfm_vendor_delivery_time',true);
      	if(!isset($vendor_delvery_schedules['enable'])) {
      		unset($tabs['wcfm_product_delivert_tab']);
      	}
      	return $tabs;
      }
      
      function wcfm_delivery_product_tab_content() {
      	global $WCFM, $product;
      	$product_id = get_the_ID();
      	$vendor_id   = wcfm_get_vendor_id_by_post( $product_id );
      	$vendor_delvery_schedules = get_user_meta($vendor_id,'wcfm_vendor_delivery_time',true); //you can find all delivery sceduled data in this variable
      	$days_map = array('Monday' => 0,'Tuesday' => 1, 'Wednesday' => 2, 'Thursday' => 3,'Friday' => 4,'Saturday' => 5,'Sunday' => 6);
      	if(isset($vendor_delvery_schedules['enable'])) {
      		if(!empty($vendor_delvery_schedules['off_days'])) {
      			$off_days_arr = [];
      			foreach ($vendor_delvery_schedules['off_days'] as $off_days) {
      				$off_days_arr[] = array_search($off_days,$days_map);
      			}
      			echo 'Week Day OFF :'.implode($off_days_arr, ',');
      		}
      		
      	}
      }

      regarding above code, if vendor will enable the “Enable Delivery Time”, then “Delivery” tab will display in his product’s page.
      Display all delivery schedule information is not possible with a small code snippet, we have provided you an example of code(display weekday off data) to how you display all data.

      Thanks.

    • #132993
      delwyn
      Participant

      Hi,

      May i know how can the Vendor “Enable Delivery Time”?

      I can’t seem to find this settings.

      Thanks!

    • #133029

      You will find the “Enable Delivery Time” vendor’s dashboard settings (PFA)

      Thanks.

      Attachments:
      You must be logged in to view attached files.
    • #133085
      delwyn
      Participant
      This reply has been marked as private.
    • #133131

      Hello,

      Have to install and activate “WCFM-Delivery”(https://wclovers.com/product/woocommerce-frontend-manager-delivery/) plugin? ” Delivery Times” tab coming from this plugin.

      You can add custom field from vendor registration form. (admin WCFM dashboard -> Settings -> Vendor registration) Or using code.
      Ref: https://wclovers.com/forums/topic/adding-new-fields-on/

      Regarding custom tab for product page, we have already provided you the code #132989 –
      Ref: https://wisdmlabs.com/blog/add-custom-tab-woocommerce-product-page/

      Thanks.

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