Jump to content

Define Virtual Product As Default


thiv

Recommended Posts

Hi,

 

How is-it possible to define "Virtual Product" as default when creating a new product ?

I want the "Virtual Product" checkbox already checked when I add a new product.

My store is selling only "Virtual Product".

 

thiv

Link to comment
Share on other sites

  • 2 years later...

You can either make a small module with hook "displayBackOfficeHeader"

 

and add this code

 

$(window).load(function(){

if(location.href.indexOf('&addproduct') > -1)

$('[name=type_product][value=2]').prop('checked', true);

});

 

or simpler (but involved core files edits)

 

find the method getType in "classes/Product.php" and change these lines

 

if (!$this->id)

return Product::PTYPE_SIMPLE;

 

to

 

if (!$this->id)

return Product::PTYPE_VIRTUAL;

Link to comment
Share on other sites

A better solution

 

https://www.prestashop.com/forums/topic/386184-free-medialoader-module-load-your-js-and-css-files-easily/?p=1987142

 

Use my free module, create a javascript file in "bo_js" (inside the module directory)

 

And add this code inside it

 

$(window).load(function(){

if(location.href.indexOf('&addproduct') > -1)

$('[name=type_product][value=2]').prop('checked', true);

});

 

This way, you don't have to modify on core files or make modules just for few lines of code

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...