Jump to content

quantity multiply by a variable -how?


Recommended Posts

Hi

 

I would like to decrease stock quantity after purchase by: quantity * variable.

the variable will be stored in "feature | value" for each product.

 

for example:

We have 100 products XYZ with feature called "multiply" and value set to 12.

 

If one bought 5 XYZ products , stock decrease -5x12. So we will have 40 products left at stock.

Order history will be shown 5 products bought by that customer.

Link to comment
Share on other sites

You might use the default PrestaShop hook called updateQuantity and do all the actions you want. I do not remember what params this hook get, but I believe you should be able to get what you want by a simple module using this hook.

 

 

Thanks!

 

But the problem is I have no idea where is the final stage of buing process, when stock is updating. Which file shall I play with? orders, cart, products ?

 

All I need is to take off from the stock, instead of X products,X * value_stored_in_prod_feature_tab.

Any other prestashop behaviour remain the same.

 

 

please, help

Link to comment
Share on other sites

I have mentioned that the most universal and best practice would be to create a custom module for this, because by editing core files of PrestaShop you will create problems with the updates in the future.

 

You might use the default PrestaShop hook called updateQuantity and do all the actions you want. I do not remember what params this hook get, but I believe you should be able to get what you want by a simple module using this hook.

 

 

Thanks!

 

But the problem is I have no idea where is the final stage of buing process, when stock is updating. Which file shall I play with? orders, cart, products ?

 

All I need is to take off from the stock instead of X products, X * value_stored_in_feature_tab.

 

 

please, help

Link to comment
Share on other sites

Thanks. What would be the simplest practice then??

 

I need to get this work ASAP,the simplest way, because I have plenty other things to do to finish this project....

I will create proper modules later on

 

 

I have mentioned that the most universal and best practice would be to create a custom module for this, because by editing core files of PrestaShop you will create problems with the updates in the future.

 

You might use the default PrestaShop hook called updateQuantity and do all the actions you want. I do not remember what params this hook get, but I believe you should be able to get what you want by a simple module using this hook.

 

 

Thanks!

 

But the problem is I have no idea where is the final stage of buing process, when stock is updating. Which file shall I play with? orders, cart, products ?

 

All I need is to take off from the stock instead of X products, X * value_stored_in_feature_tab.

 

 

please, help

Link to comment
Share on other sites

Hooks are used from modules, if you want to use the this as I wrote earlier, you must use a module.

 

Really, a module is the simplest way to do this as I see it. ;)

 

I really have no time to lern how to write a module. Which funcion in which file shall I edit?

Link to comment
Share on other sites

Hooks are used from modules, if you want to use the this as I wrote earlier, you must use a module.

 

Really, a module is the simplest way to do this as I see it. ;)

 

I really have no time to lern how to write a module. Which funcion in which file shall I edit?

 

I belive, all I need is to edit a line in one of the core files:

 

from ... -quantity .... change to: -(quantiy * something)

 

edit:

I think I should be able to do this by editing updateQuantity function in classes/product.php file, am I right?

Link to comment
Share on other sites

I have mentioned that the most universal and best practice would be to create a custom module for this, because by editing core files of PrestaShop you will create problems with the updates in the future.

 

You might use the default PrestaShop hook called updateQuantity and do all the actions you want. I do not remember what params this hook get, but I believe you should be able to get what you want by a simple module using this hook.

 

 

Thanks!

 

But the problem is I have no idea where is the final stage of buing process, when stock is updating. Which file shall I play with? orders, cart, products ?

 

All I need is to take off from the stock instead of X products, X * value_stored_in_feature_tab.

 

 

please, help

 

But Richard, I think if I simply override a class I would be able to update prestashop without any problem as well?

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...