Overriding Dokan plugin template is easy!

Published by WP Doctor on

This quick-reading post will help you to know about overriding a template of Dokan Multivendor pluginSometimes you may need to modify the core plugin file. Like as you need to remove an option from a file while it does not have any necessary action/filter. Now, you are thinking that “If I modify into the core file then I will lose everything during the plugin update”.

No need to worry! you can apply an alternate solution to modify the file via a child theme. Please keep a note –

You can only override a template file through your child theme. You can use this plugin to create child-theme.

How to override Dokan template file?

Dokan has multiple template files to operate its functionality like as –

  • Dashboard
  • Store page
  • Product upload and edit page
  • Store-list page and others.

If you can check the file structure of Dokan-lite or Dokan Pro then you will find the structure like this –

To get those files just open your website’s root folder and then open wp-content → plugins → dokan-lite 

Inside the dokan-lite folder, you are seeing that there is a folder called templates. If you have seen it then keep a note that you can override all the files which are available inside this templates folder through your child theme and the plugin update would not change anything (Until the plugin does not have any new changes inside template file)

Creating a folder inside the child theme

Just imagine that you are using a child theme called my-child-theme and you need to override a product template file which is inside dokan-lite/templates/products folder.

Now, inside the products folder, there are many template files like as new-product-single.php or new-product.php. Let’s pick new-product-single.php file to override.

Step 1: Create a folder called dokan” inside your child theme and then it will look like – wp-content/themes/my-child-  theme/dokan

Step 2: After completing step 1, just create a folder called “products” inside the dokan folder which you have created on step 1 (my-child-theme/dokan/products). Because this products folder contains the new-product-single.php file.

Step 3: Now, copy the new-product-single.php file inside the products folder. It will look like my-child-theme/dokan/products/new-product-single.php file. 

If you have completed the 3rd step then you are done. Now, you can modify the dokan-pro templates file also by following the same method.

Note : The folder called “dokan” is same for both dokan-lite or pro version.


7 Comments

Navneet sharma · April 5, 2019 at 7:22 pm

Hi,

I have follow the steps and nothing change .

i have make a child theme under this i have make the folder dokan-lite>template>dashboard>dashboard.php.
but whne i try to add some text in this file and update its not reflecting.

any helps please!

    WP Doctor · April 8, 2019 at 11:59 am

    Hello Navneet,

    We did not write anywhere in our post that you have to create a template folder inside the child-theme/dokan folder. So, please correct the folder structure- child-theme/dokan/dashboard/dashboard.php 🙂

rogodessa · April 23, 2019 at 2:06 am

Hello!

I did according to what is written in this article. Created the necessary folders in the child theme, copied the template file wp-content/themes/martfury-child/dokan/settings/address-form.php

But changes are not reflected.

Please, help

    WP Doctor · April 23, 2019 at 9:05 am

    Hello,

    We have checked and working fine. Please make sure that you are changing something which is only coming from this file. If you are changing any function which calls back is on another file then it won’t work 🙂

      rogodessa · April 23, 2019 at 6:16 pm

      Thanks for the answer!

      Problem found. In the options table “stylesheet” was the value “martfury-child/..” (need “martfury-child”). Therefore, the locate_template() function returned a wrong path – /wp-content/themes/martfury-child/../dokan/settings/address-form.php

        WP Doctor · May 9, 2019 at 10:09 pm

        Great to hear that you found the problem 🙂

Leave a Reply

%d bloggers like this: