I have a store with customer groups for different customer "levels". Each level has discounted pricing that is set up using tier pricing.
My problem is the tier pricing does not apply if a customer first adds an item to their cart and then logs in. I expect that when they log in their cart would update with their customer group discounts.
I want the cart pricing to apply immediately when the user logs in, including using the ajax login on the checkout page.
How can I write a module to update the pricing after a user logs in? I'm looking for a particular event to hook into for user login and the right command to 'refresh' the cart programatically. This would ideally include refreshing the pricing on the checkout page if the user logs in from there.
Update (first attempt)
I have tracked down a bit of code that refreshes the cart items' prices. In order to test this I made a simple controller that runs this code:
/** $this->checkoutSession \Magento\Checkout\Model\Session **/ $quote = $this->checkoutSession->getQuote()->collectTotals()->save();
When I log in and load a page that runs the above code, cart prices are properly refreshed. However, when I try this code inside of an Observer, I have no luck. For my observer I have tried a few different events in order to test, here is a list of those events:
I know the code works but I none of the above events are doing it. I think if I get the correct event I'll be close to figuring this out.