• Resolved mwitthus

    (@mwitthus)


    Is there a way to change the default product type to “Variable” for when a Vendor lists their products. All my vendors will be using Variable products, so the Simple product type won’t be used. It’s also confusing to my vendors when they add a product with variations because they always miss the part where they have to change the product type to a Variable product.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello @mwitthus ,

    At the moment I am unable to suggest any direct hook/filter to modify the default product type to variable. But if you want to explore further you can take a look at this file – dokan-lite\includes\Dashboard\Templates\Products.php here at line #296 you can set the default product type.

    Any modification in this file will be removed when Dokan Lite will be updated so this is not the recommended way to modify.

    Thank you.

    Thread Starter mwitthus

    (@mwitthus)

    So you’re saying whenever there is a Dokan update, the file will be changed back to default?

    Hello @mwitthus ,

    Unfortunately, yes. At the moment I am unable to suggest any direct hook to make the changes through a child theme. You can try with this filet “dokan_product_types”. In my test, I was unable to force anything other than simple product types.

    If you only want variable product type then using that filter you can remove all other product types though.

    Thank you.

    Thread Starter mwitthus

    (@mwitthus)

    Actually yeah I would like to have only variable product types. Is there a way I can change some code to only variable product types?

    Hello @mwitthus ,

    There are several ways to do that. You can simply replace these lines from dokan-lite/templates/products/new-product.single.php look for the product type selection codes. They should be around line #180 – https://prnt.sc/ssnkd8

    Replace these lines with these –

    <select name="product_type" class="dokan-form-control" id="product_type">
         <?php foreach ( $product_types as $key => $value ) { if ($key == "variable") {?>
               <option value="<?php echo esc_attr( $key ) ?>" <?php selected($product_type, $key ) ?>><?php echo esc_html( $value ) ?></option>
          <?php } } ?>
    </select>

    After modification save this file under your-theme/dokan/products folder with exact same name.

    Alternatively, you can use this filter – dokan_product_types if you are comfortable to write some code for modification.

    Thank you.

    Thread Starter mwitthus

    (@mwitthus)

    Thank you for the info. Will this new code remain the same even when a Dokan update is installed?

    I’ve updated the file with the new code you gave me and there’s one small problem. After you click “Create Product”, the product is still created as a simple product. In order to get it to change to a variable product, the vendor must click the “Save Product” button on the edit product page. Once they do that, it will then switch to a variable product. This is not a major problem to be honest, but it would be nice if the product was created immediately as a variable product after they click “Create Product” on the first edit product page.

    Hello @mwitthus ,

    The file I mentioned is a template file so you are able to override the template file through your child theme. Save your modified file under your-theme/dokan/products folder.

    The issue that the product is first saved as a simple product type will be hard to change without modifying the core files. So, I will suggest to ignore that part as of now.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Change Default Product Type to “Variable”’ is closed to new replies.