Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards

Custom page in Seller dashboard

MultivendorX Pro

Resolved
Viewing 9 reply threads
  • Author
    Posts
    • #194961
      Kuzman Primdjanov
      Participant

      Hello guys,
      I followed the instructions in this topic, and I was able to add a new menu in the seller dashboard, but I can’t link a page to it (the url of the menu link is blank, leads to mysite.com/dashboard//):
      https://multivendorx.com/support-forum/topic/custom-vendor-nav-menu-additions-setting-the-end-points/

      I guess the p[roblem is probable the setting of the menu url.

      This is my full code:

      /* wcmp custom tab all function*/

      add_filter( ‘wcmp_vendor_dashboard_nav’, ‘add_wcmp_vendor_dashboard_nav’ );

      function add_wcmp_vendor_dashboard_nav($nav) {
      $nav[‘custom_wcmp_menu’] = array(
      ‘label’ => __(‘Customers’, ‘dc-woocommerce-multi-vendor’), // menu label
      ‘url’ => wcmp_get_vendor_dashboard_endpoint_url( get_wcmp_vendor_settings( ‘wcmp_custom_endpoint’, ‘vendor’, ‘general’, ‘custom-wcmp-menu’ ) ), // menu url
      ‘capability’ => true, // capability if any
      ‘position’ => 15, // position of the menu
      ‘submenu’ => array(), // submenu if any
      ‘link_target’ => ‘_self’,
      ‘nav_icon’ => ‘dashicons dashicons-id-alt’, // menu icon
      );
      return $nav;
      }

      add_filter( “settings_vendor_general_tab_options”, “wcmp_add_custom_endpoint_option” );
      function wcmp_add_custom_endpoint_option($settings_tab_options){
      $end_points = $settings_tab_options[‘sections’][‘wcmp_vendor_general_settings_endpoint_ssection’][‘fields’];
      $custom_end_point = array(
      ‘wcmp_custom_endpoint’ => array(‘title’ => __(‘custom menu’, ‘wcmp-afm’), ‘type’ => ‘text’, ‘id’ => ‘wcmp_custom_endpoint’, ‘label_for’ => ‘wcmp_custom_endpoint’, ‘name’ => ‘wcmp_custom_endpoint’, ‘hints’ => __(‘Set endpoint for vendor custom page’, ‘wcmp-afm’), ‘placeholder’ => ‘custom menu’),
      );
      $settings_tab_options[‘sections’][‘wcmp_vendor_general_settings_endpoint_ssection’][‘fields’] = array_merge($end_points,$custom_end_point);
      return $settings_tab_options;
      }

      add_filter( “settings_vendor_general_tab_new_input”, “wcmp_custom_end_point_save”, 10, 2 );

      function wcmp_custom_end_point_save($new_input, $input){
      if (isset( $input[‘wcmp_custom_endpoint’] ) && !empty( $input[‘wcmp_custom_endpoint’] )) {
      $new_input[‘wcmp_custom_endpoint’] = sanitize_text_field( $input[‘wcmp_custom_endpoint’] );
      }
      return $new_input;
      }

      add_action( ‘wcmp_vendor_dashboard_custom-wcmp-menu_endpoint’, ‘wcmp_vendor_dashboard_custom_wcmp_menu_endpoint’ );

      // function wcmp_vendor_dashboard_custom_wcmp_menu_endpoint() {
      // echo ‘test’;
      // }

      function wcmp_vendor_dashboard_custom_wcmp_menu_endpoint() {
      global $WCMp;
      $WCMp->template->get_template(‘customer-list.php’);
      }

      add_filter(‘wcmp_endpoints_query_vars’, ‘wcmp_add_vendor_media_endpoint’);

      function wcmp_add_vendor_media_endpoint($endpoints){

      $endpoints[‘custom-wcmp-menu’] = array(
      ‘label’ => __(‘Custom Menu’, ‘dc-woocommerce-multi-vendor’),
      ‘endpoint’ => get_wcmp_vendor_settings(‘wcmp_custom_endpoint’, ‘vendor’, ‘general’, ‘custom-wcmp-menu’)
      );
      return $endpoints;
      }

    • #194982

      @Kuzman Primdjanov Our developer team has checked the code and it is working perfectly fine. Kindly check this part of the code carefully again –

      
      function wcmp_vendor_dashboard_custom_wcmp_menu_endpoint() { 
      global $WCMp; 
      $WCMp->template->get_template(‘customer-list.php’);
       } 
      
      Copy
    • #195215
      Kuzman Primdjanov
      Participant

      Hi,
      Regarding that part:
      $WCMp->template->get_template(‘customer-list.php’);

      The path to the file should be relative to what? I want it to be in my theme folder, is there a special naming convention I should follow, so the arrow functions on $WCMp object don’t require full path? Please elaborate more….

      Thank you!

    • #195226

      With the get template you are fetching the template folder. Then you will have to give the path of the template file to fetch that template file.

      • #195423
        Kuzman Primdjanov
        Participant

        @Sangita
        My customer-list.php is in dc-product-vendor folder in my theme (hello-elementor-child/dc-product-vendor/customer-list.php) but $WCMp->template->get_template(‘/dc-product-vendor/customer-list.php’); does not work;
        Moreover, I had another question that is still unanswered:
        the url of the menu link is blank, leads to mysite.com/dashboard/ – what about this?
        My MultiVendorX plugin version is 4.0.23

        Best regards,
        Stefan

        • #195424
          Kuzman Primdjanov
          Participant

          Update:
          I managed to fix the endpoint (URL part) after I found this in the logs:
          The get_wcmp_vendor_settings function is deprecated since version 4.0.0. Replace with get_mvx_vendor_settings.

          Still not fetching the template thought….

    • #195433

      The function fetches the template folder of the core plugin folder. Now as it is in the theme, include the file normally in the theme folder.
      Now for the issue with the url, you need to change the upper code for MVX as it is written for WCMP. But as we have changed hooks hence you will have to modify the code according to that.

    • #195435
      Kuzman Primdjanov
      Participant

      Sangita, please elaborate further, I need assistance here; According to what? Which functions have been changed, where can I look them up? I provided the full code exactly for this reason – and initialy you told me it was OK….

    • #195437
      Kuzman Primdjanov
      Participant

      Maybe @abhirup can jump in on this, as the code I’m trying to modify is basically what he suggested in the other thread I linked to?

    • #195441

      The below code is the MVX version of the above shared code –

      
      // add custom endpoint
      add_filter('mvx_endpoints_query_vars', 'add_mvx_endpoints_query_vars_new');
      // add custom menu to vendor dashboard
      add_filter('mvx_vendor_dashboard_nav', 'add_tab_to_vendor_dashboard');
      // display content of custom endpoint
      add_action('mvx_vendor_dashboard_custom-mvx-menu_endpoint', 'custom_menu_endpoint_content');
      
      function add_mvx_endpoints_query_vars_new($endpoints) {
          $endpoints['custom-mvx-menu'] = array(
              'label' => __('Custom Menu', 'multivendorx'),
              'endpoint' => get_mvx_vendor_settings('mvx_custom_endpoint', 'seller_dashboard', 'custom-mvx-menu')
              );
              return $endpoints;
          }
      function add_tab_to_vendor_dashboard($nav) {
          $nav['custom_mvx_menu'] = array(
              'label' => __('Custom Menu', 'multivendorx'), // menu label
              'url' => mvx_get_vendor_dashboard_endpoint_url( get_mvx_vendor_settings( 'mvx_custom_endpoint', 'seller_dashboard', 'custom-mvx-menu' ) ), // menu url
              'capability' => true, // capability if any
              'position' => 75, // position of the menu
              'submenu' => array(), // submenu if any
              'link_target' => '_self',
              'nav_icon' => 'dashicons-admin-generic', // menu icon
              );
          return $nav;
          }
      function custom_menu_endpoint_content(){
          echo '<div class="mvx_form1">';
          echo '<p>Custom Menu content</p>';
          echo '</div>';
          }
      
      Copy
    • #196345
      Kuzman Primdjanov
      Participant

      Thank you, I managed to customize it to fit my requirements 🙂

    • #196359

      Happy to hear that. We are closing this thread. If you need help or face issue in future please open a new support thread.

Viewing 9 reply threads

The topic ‘Custom page in Seller dashboard’ is closed to new replies.