Jump to content

Lowest Price of all groups


macjo

Recommended Posts

I will try to explain you my problem with an example.

I have 2 clients (Client A, B), 2 groups (Group 1, 2) and 1 product in my shop.
The product has 2 specific prices:

  • Price of 1Euro for "group1"
  • Price of 2Euros for "group2"

Client A belongs to group2 and Client B belongs to group1 and group2.
They both have "default group" "group2", which means that when both clients check the product they both will have a price of 2Euros.

Now what I'm trying to do is for every client to get the cheapest price of all the groups that they belong to. Any ideas where to start with this problem?
I could change PrestaShop's code to do this but that it's not the point. I want to do that threw a module.

Does anyone have an idea of what classes need to be overwritten or if a hook is available for this purpose?

If someone could send me in the right direction it would be awesome.
Thank you in advance

Edited by macjo (see edit history)
Link to comment
Share on other sites

Here is my solution to my own question. I'm not going to write the all code here since I did an override of the class and only modified a small bit. Feel free to write me if you want the full answer.

Solution:

  • Override Class SpecificPriceCore (Classes/SpecificPrice.php), override function getSpecificPrice()
  • Modify the query to accept multiple group IDs
  • Create a function that requests all the Group IDs from the client
  • Call the function that you just created in getSpecificPrice()
  • Add the IDs in the query

Cheers

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