MacJ
MacJ

Reputation: 91

Prestashop - Lowest Price of all groups

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:

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

Upvotes: 0

Views: 165

Answers (1)

MacJ
MacJ

Reputation: 91

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

Upvotes: 1

Related Questions