MultivendorX Pro
-
AuthorPosts
-
-
August 9, 2023 at 12:39 AM #194961Kuzman PrimdjanovParticipant
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;
} -
August 9, 2023 at 4:40 PM #194982Sangita Support SquadKeymaster
@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 -
August 17, 2023 at 3:25 AM #195215Kuzman PrimdjanovParticipant
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!
-
August 17, 2023 at 4:25 PM #195226Sangita Support SquadKeymaster
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.
-
August 23, 2023 at 1:10 PM #195423Kuzman PrimdjanovParticipant
@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.23Best regards,
Stefan-
August 23, 2023 at 1:19 PM #195424Kuzman PrimdjanovParticipant
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….
-
-
-
August 23, 2023 at 2:25 PM #195433Sangita Support SquadKeymaster
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. -
August 23, 2023 at 2:49 PM #195435Kuzman PrimdjanovParticipant
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….
-
August 23, 2023 at 2:52 PM #195437Kuzman PrimdjanovParticipant
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?
-
August 23, 2023 at 3:07 PM #195441Sangita Support SquadKeymaster
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 -
September 17, 2023 at 4:52 PM #196345Kuzman PrimdjanovParticipant
Thank you, I managed to customize it to fit my requirements 🙂
-
September 18, 2023 at 9:49 AM #196359Sangita Support SquadKeymaster
Happy to hear that. We are closing this thread. If you need help or face issue in future please open a new support thread.
-
-
AuthorPosts
The topic ‘Custom page in Seller dashboard’ is closed to new replies.