Search code examples
phpopencartopencart2.x

OpenCart add to cart by wholesale price for wholesale customer group


I am using OpenCart 2.2.0. I have two customer groups-regular and wholesale. If logged, regular group customers can add products to cart by regular price and that part is ok. But I do not know how to make my wholesale group to add product to cart by wholesale price. This group sees both regular and wholesale price, but if logged as wholesale customer, I need them to add to cart by wholesale price. I've looked at cart.php controller file, but really do not know which file(s) should I modify in order for this to work.


Solution

  • The file in question is somewhere I'd never thought it would be.It's in system/library/checkout/cart.php There is an array in which price is defined, so all you need to do is define price array value as wholesale and total as wholesale * quantity for wholesale customer group. And then, change in controller/cart/cart.php and controller/common/cart.php accordingly. Bingo! I hope this helps someone, took me two days to figure this out!